Skip to content

Commit

Permalink
Merge pull request #500 from ripe-tech/ns/499-environment
Browse files Browse the repository at this point in the history
#499 Load environment file bases on config
  • Loading branch information
NFSS10 authored Mar 10, 2023
2 parents 5256394 + 76be7b3 commit 9a7493c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
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.
* @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;

// 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";
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

1 comment on commit 9a7493c

@vercel
Copy link

@vercel vercel bot commented on 9a7493c Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ripe-sdk – ./

ripe-sdk-git-master-platforme.vercel.app
ripe-sdk-docs-csr.vercel.app
ripe-sdk-platforme.vercel.app

Please sign in to comment.