The internally used version of the Babylon.js library has been updated from 4.1.0
to the latest stable version 4.2.0
.
See Babylon.js release notes for detailed description of what this update changes under the hood.
You can check & update the versions used by your project with the following steps:
package.json
within your project4.2.0
please update them:4.1.0
to 4.2.0
.~
, ^
etc. for the version number but only write 4.2.0
."@babylonjs/core": "4.2.0"
.npm run watch
)npm i
to update all dependencies to the new versions from your package.json
Type exports of the viewer have been adjusted for easier use which results in the following improvements for your code:
StructureJson
etc. are exported by the viewers index file:Before:
import { Viewer } from '@combeenation/3d-viewer';
import { VariantInstance } from '@combeenation/3d-viewer/api/classes/variantInstance';
import { Mesh } from '@babylonjs/core/Meshes/mesh';
import { Vector3 } from '@babylonjs/core/Maths/math.vector';
import { Color4 } from '@babylonjs/core/Maths/math.color';
import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera';
/**
* @return {import('@combeenation/3d-viewer/dist/lib-cjs/api/util/typeExports').StructureJson}
*/
export function createSpec() {
/* ... */
}
Now:
import { ViewerVariantInstance, Mesh, Vector3, Color4, ArcRotateCamera } from '@combeenation/3d-viewer';
/**
* @return {StructureJson}
*/
export function createSpec() {
/* ... */
}
Simplify imports of 3d viewer types:
from '@combeenation/3d-viewer/
from '@combeenation/3d-viewer'
:// E.g. change
import { VariantInstance } from '@combeenation/3d-viewer/api/classes/variantInstance';
// to
import { VariantInstance } from '@combeenation/3d-viewer';
'@combeenation/3d-viewer'
to 1 statementSimplify types in JSDoc annotations:
import('@combeenation
in JSDoc annotations// E.g. change
@return {import('@combeenation/3d-viewer/dist/libcjs/api/util/typeExports').StructureJson}
// to
@return {StructureJson}
Use Babylon.js type imports from viewer:
from '@babylonjs
@combeenation/3d-viewer
npm run watch
gives you any errorsRemove obsolete Babylon.js dependencies:
from '@babylonjs
package.json
npm i
Remove obsolete type imports:
no-unused-vars
no-unused-vars
linenpm run watch
gives you any errorsno-unused-vars
statementColors applied to PBR materials appeared "washed out" in earlier viewer versions. The color which appeared on the screen was often a lot lighter than one would have expected from its color code.
The new viewer fixes this by automatically converting colors given to its API (e.g. to commitParameters
) from gamma to linear color space.
commitParameters
) appear on the screen. Please check & adjust all your colors carefully after updating the viewer.
Positions within the 3d scene can now be declared using PlacementDefinition
inside the specs SceneJson.placements
.
Those placements can be used to trigger animated camera movements using the new camera movement API and AnimationDefinition
inside the specs SceneJson.animations
.
/**
* @return {StructureJson}
*/
export function createSpec() {
return {
scene: {
// ...
// Define placements & animations in spec:
placements: {
Height60: {
position: '(-0.6073864925275645, 0.4765578799104585, -1.284793058907506)',
target: '(-0.030564361711816836, 0.26223482532257786, -0.1034106283975893)',
},
Height100: {
position: '(-0.5034608339970097, 0.9162828478182772, -1.4399870356436006)',
target: '(0.11190323895696523, 0.47328146232722085, -0.016705972101674342)',
},
},
animations: {
DefaultCameraAnimation: {
ease: 'Power3.easeInOut',
duration: 0.8,
},
},
// ...
},
// ...
};
}
// ...
// Perform a simple animated camera movement:
const camPlacementName = isHeight100 ? 'Height100' : 'Height60';
viewer.moveActiveCameraTo(camPlacementName, 'DefaultCameraAnimation');
// Perform a series of animated camera movements:
await viewer.moveActiveCameraTo('Height60', 'DefaultCameraAnimation');
await viewer.moveActiveCameraTo('Height100', 'DefaultCameraAnimation');
await viewer.moveActiveCameraTo('Height60', 'DefaultCameraAnimation');
// ...
You can use the GreenSock Ease Visualizer to create an animation of your liking and simply copy the ease
function shown at the bottom of the visualizer into the ease
property of your AnimationDefinition
.
Generated using TypeDoc