three-render-objects 1.40.5 → 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.
|
@@ -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);
|
|
@@ -422,13 +454,21 @@ var threeRenderObjects = Kapsule({
|
|
|
422
454
|
},
|
|
423
455
|
tbControls: function tbControls(state) {
|
|
424
456
|
return state.controls;
|
|
425
|
-
}
|
|
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
|
+
}
|
|
426
466
|
},
|
|
427
467
|
stateInit: function stateInit() {
|
|
428
468
|
return {
|
|
429
469
|
scene: new three.Scene(),
|
|
430
470
|
camera: new three.PerspectiveCamera(),
|
|
431
|
-
|
|
471
|
+
timer: new three.Timer(),
|
|
432
472
|
tweenGroup: new Group(),
|
|
433
473
|
lastRaycasterCheck: 0
|
|
434
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,11 +53,11 @@
|
|
|
53
53
|
"polished": "4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"three": ">=0.
|
|
56
|
+
"three": ">=0.179"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@babel/core": "^7.29.0",
|
|
60
|
-
"@babel/preset-env": "^7.29.
|
|
60
|
+
"@babel/preset-env": "^7.29.2",
|
|
61
61
|
"@rollup/plugin-babel": "^7.0.0",
|
|
62
62
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
63
63
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"@types/react": "^19.2.14",
|
|
66
66
|
"postcss": "^8.5.8",
|
|
67
67
|
"rimraf": "^6.1.3",
|
|
68
|
-
"rollup": "^4.
|
|
69
|
-
"rollup-plugin-dts": "^6.4.
|
|
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"
|