Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#499 Load environment file bases on config #500

Merged
merged 6 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Update `.gitignore` to ignore CSR documentation compilation files - [#478](https://github.com/ripe-tech/ripe-sdk/issues/478)
* Update CSR documentation with proper configuration with title and logo - [#478](https://github.com/ripe-tech/ripe-sdk/issues/478)
* Improve CSR deinitialization logic - [#493](https://github.com/ripe-tech/ripe-sdk/issues/493)
* Load environment file based on config - [499](https://github.com/ripe-tech/ripe-sdk/issues/499)

### Fixed

Expand Down
11 changes: 5 additions & 6 deletions src/js/api/brand.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,13 @@ ripe.Ripe.prototype.getFontUrl = function(name, format, options) {
/**
* Returns the URL for the environment file of the 3D scene.
*
* @param {Object} options A map with options, such as:
* - 'brand' - The brand of the model.
* - 'model' - The name of the model.
* - 'version' - The version of the build, defaults to latest.
* @param {String} name The name of the environment map.
* @param {String} format The file format of the environment map.
* @param {Object} options A map with options.
3rdvision marked this conversation as resolved.
Show resolved Hide resolved
* @returns {String} The URL of the environment for the 3D scene.
*/
ripe.Ripe.prototype.get3dSceneEnvironmentUrl = function(options) {
return "https://www.dl.dropboxusercontent.com/s/o0v07nn5egjrjl5/studio2.hdr";
ripe.Ripe.prototype.getSceneEnvironmentUrl = function(name, format, options) {
return `https://cdn.platforme.com/3d/environment/${name}.${format}`;
};

/**
Expand Down
11 changes: 8 additions & 3 deletions src/js/visual/configurator-csr.js
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,9 @@ ripe.ConfiguratorCsr.prototype._unpackSceneOptions = function(options) {
const cameraOptions = {};
const zoomOptions = {};

// unpacks root options
const environment = options.environment;

3rdvision marked this conversation as resolved.
Show resolved Hide resolved
// unpacks renderer options
rendererOptions.toneMapping = options.tone_mapping
? ripe.CsrUtils.toToneMappingValue(options.tone_mapping)
Expand Down Expand Up @@ -1350,6 +1353,7 @@ ripe.ConfiguratorCsr.prototype._unpackSceneOptions = function(options) {
}

return {
environment: environment,
rendererOptions: rendererOptions,
cameraOptions: cameraOptions,
zoomOptions: zoomOptions
Expand Down Expand Up @@ -1381,8 +1385,9 @@ ripe.ConfiguratorCsr.prototype._loadCsrAssets = async function(
this.dracoLoader = ripe.CsrUtils.loadDracoLoader();

// computes environment file URL
const envUrl = this.owner.get3dSceneEnvironmentUrl();
const envFormat = "hdr";
const environment = sceneOptions.environment || "studio2";
const environmentFormat = "hdr";
3rdvision marked this conversation as resolved.
Show resolved Hide resolved
const environmentUrl = this.owner.getSceneEnvironmentUrl(environment, environmentFormat);

const optionsParams = initialsOptions.options || {};

Expand Down Expand Up @@ -1440,7 +1445,7 @@ ripe.ConfiguratorCsr.prototype._loadCsrAssets = async function(
] = await Promise.all([
this._loadMesh(meshUrl, meshFormat),
fontUrl ? this._loadExternalFont(font, fontUrl) : null,
envUrl ? ripe.CsrUtils.loadEnvironment(envUrl, envFormat) : null,
environmentUrl ? ripe.CsrUtils.loadEnvironment(environmentUrl, environmentFormat) : null,
baseTextureUrl ? ripe.CsrUtils.loadTexture(baseTextureUrl) : null,
displacementTextureUrl ? ripe.CsrUtils.loadTexture(displacementTextureUrl) : null,
metallicTextureUrl ? ripe.CsrUtils.loadTexture(metallicTextureUrl) : null,
Expand Down