three-render-objects 1.40.4 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/three-render-objects.js +33062 -24484
- package/dist/three-render-objects.js.map +1 -1
- package/dist/three-render-objects.min.js +2 -2
- package/dist/three-render-objects.mjs +51 -7
- package/package.json +15 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SphereGeometry, Color, TextureLoader, SRGBColorSpace, MeshBasicMaterial, BackSide, Vector2, WebGLRenderer, Mesh,
|
|
1
|
+
import { SphereGeometry, Color, TextureLoader, SRGBColorSpace, MeshBasicMaterial, BackSide, Vector2, WebGLRenderer, Mesh, Timer, PerspectiveCamera, Scene, Raycaster, Vector3, Box3 } from 'three';
|
|
2
2
|
import { WebGPURenderer } from 'three/webgpu';
|
|
3
3
|
import { TrackballControls } from 'three/examples/jsm/controls/TrackballControls.js';
|
|
4
4
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
|
@@ -119,6 +119,38 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
var _materialDispose = function materialDispose(material) {
|
|
123
|
+
if (material instanceof Array) {
|
|
124
|
+
material.forEach(_materialDispose);
|
|
125
|
+
} else {
|
|
126
|
+
if (material.map) {
|
|
127
|
+
material.map.dispose();
|
|
128
|
+
}
|
|
129
|
+
material.dispose();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var _deallocate = function deallocate(obj) {
|
|
133
|
+
if (obj.geometry) {
|
|
134
|
+
obj.geometry.dispose();
|
|
135
|
+
}
|
|
136
|
+
if (obj.material) {
|
|
137
|
+
_materialDispose(obj.material);
|
|
138
|
+
}
|
|
139
|
+
if (obj.texture) {
|
|
140
|
+
obj.texture.dispose();
|
|
141
|
+
}
|
|
142
|
+
if (obj.children) {
|
|
143
|
+
obj.children.forEach(_deallocate);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var emptyObject = function emptyObject(obj) {
|
|
147
|
+
while (obj.children.length) {
|
|
148
|
+
var childObj = obj.children[0];
|
|
149
|
+
obj.remove(childObj);
|
|
150
|
+
_deallocate(childObj);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
122
154
|
var three = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
|
|
123
155
|
: {
|
|
124
156
|
WebGLRenderer: WebGLRenderer,
|
|
@@ -135,7 +167,7 @@ var three = window.THREE ? window.THREE // Prefer consumption from global THREE,
|
|
|
135
167
|
SphereGeometry: SphereGeometry,
|
|
136
168
|
MeshBasicMaterial: MeshBasicMaterial,
|
|
137
169
|
BackSide: BackSide,
|
|
138
|
-
|
|
170
|
+
Timer: Timer
|
|
139
171
|
};
|
|
140
172
|
var threeRenderObjects = Kapsule({
|
|
141
173
|
props: {
|
|
@@ -229,7 +261,7 @@ var threeRenderObjects = Kapsule({
|
|
|
229
261
|
methods: {
|
|
230
262
|
tick: function tick(state) {
|
|
231
263
|
if (state.initialised) {
|
|
232
|
-
state.controls.enabled && state.controls.update && state.controls.update(Math.min(1, state.
|
|
264
|
+
state.controls.enabled && state.controls.update && state.controls.update(Math.min(1, state.timer.update().getDelta())); // timedelta is required for fly controls
|
|
233
265
|
|
|
234
266
|
state.postProcessingComposer ? state.postProcessingComposer.render() // if using postprocessing, switch the output to it
|
|
235
267
|
: state.renderer.render(state.scene, state.camera);
|
|
@@ -289,10 +321,14 @@ var threeRenderObjects = Kapsule({
|
|
|
289
321
|
} else {
|
|
290
322
|
var camPos = Object.assign({}, camera.position);
|
|
291
323
|
var camLookAt = getLookAt();
|
|
292
|
-
state.tweenGroup.add(new Tween(camPos).to(finalPos, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(setCameraPos).
|
|
324
|
+
state.tweenGroup.add(new Tween(camPos).to(finalPos, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(setCameraPos).onComplete(function () {
|
|
325
|
+
state.tweenGroup.remove(this);
|
|
326
|
+
}).start());
|
|
293
327
|
|
|
294
328
|
// Face direction in 1/3rd of time
|
|
295
|
-
state.tweenGroup.add(new Tween(camLookAt).to(finalLookAt, transitionDuration / 3).easing(Easing.Quadratic.Out).onUpdate(setLookAt).
|
|
329
|
+
state.tweenGroup.add(new Tween(camLookAt).to(finalLookAt, transitionDuration / 3).easing(Easing.Quadratic.Out).onUpdate(setLookAt).onComplete(function () {
|
|
330
|
+
state.tweenGroup.remove(this);
|
|
331
|
+
}).start());
|
|
296
332
|
}
|
|
297
333
|
return this;
|
|
298
334
|
}
|
|
@@ -418,13 +454,21 @@ var threeRenderObjects = Kapsule({
|
|
|
418
454
|
},
|
|
419
455
|
tbControls: function tbControls(state) {
|
|
420
456
|
return state.controls;
|
|
421
|
-
}
|
|
457
|
+
},
|
|
458
|
+
// to be deprecated
|
|
459
|
+
_destructor: function _destructor(state) {
|
|
460
|
+
var _state$controls, _state$renderer, _state$postProcessing;
|
|
461
|
+
emptyObject(state.scene);
|
|
462
|
+
(_state$controls = state.controls) === null || _state$controls === void 0 || _state$controls.dispose();
|
|
463
|
+
(_state$renderer = state.renderer) === null || _state$renderer === void 0 || _state$renderer.dispose();
|
|
464
|
+
(_state$postProcessing = state.postProcessingComposer) === null || _state$postProcessing === void 0 || _state$postProcessing.dispose();
|
|
465
|
+
}
|
|
422
466
|
},
|
|
423
467
|
stateInit: function stateInit() {
|
|
424
468
|
return {
|
|
425
469
|
scene: new three.Scene(),
|
|
426
470
|
camera: new three.PerspectiveCamera(),
|
|
427
|
-
|
|
471
|
+
timer: new three.Timer(),
|
|
428
472
|
tweenGroup: new Group(),
|
|
429
473
|
lastRaycasterCheck: 0
|
|
430
474
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-render-objects",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"description": "Easy way to render ThreeJS objects with built-in interaction defaults",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -53,23 +53,23 @@
|
|
|
53
53
|
"polished": "4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"three": ">=0.
|
|
56
|
+
"three": ">=0.179"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
61
|
-
"@rollup/plugin-babel": "^
|
|
62
|
-
"@rollup/plugin-commonjs": "^
|
|
63
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
64
|
-
"@rollup/plugin-terser": "^0.
|
|
65
|
-
"@types/react": "^19.
|
|
66
|
-
"postcss": "^8.5.
|
|
67
|
-
"rimraf": "^6.
|
|
68
|
-
"rollup": "^4.
|
|
69
|
-
"rollup-plugin-dts": "^6.
|
|
59
|
+
"@babel/core": "^7.29.0",
|
|
60
|
+
"@babel/preset-env": "^7.29.2",
|
|
61
|
+
"@rollup/plugin-babel": "^7.0.0",
|
|
62
|
+
"@rollup/plugin-commonjs": "^29.0.2",
|
|
63
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
64
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
65
|
+
"@types/react": "^19.2.14",
|
|
66
|
+
"postcss": "^8.5.8",
|
|
67
|
+
"rimraf": "^6.1.3",
|
|
68
|
+
"rollup": "^4.60.1",
|
|
69
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
70
70
|
"rollup-plugin-postcss": "^4.0.2",
|
|
71
|
-
"three": "^0.
|
|
72
|
-
"typescript": "^
|
|
71
|
+
"three": "^0.183.2",
|
|
72
|
+
"typescript": "^6.0.2"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=12"
|