three-render-objects 1.38.1 → 1.39.1
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,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WebGPURenderer } from 'three/webgpu';
|
|
1
|
+
import { SphereGeometry, Color, TextureLoader, SRGBColorSpace, MeshBasicMaterial, BackSide, Vector2, WebGLRenderer, Mesh, Clock, PerspectiveCamera, Scene, Raycaster, Vector3, Box3 } from 'three';
|
|
2
|
+
import { WebGPURenderer } from 'three/build/three.webgpu.js';
|
|
3
3
|
import { TrackballControls } from 'three/examples/jsm/controls/TrackballControls.js';
|
|
4
4
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
|
5
5
|
import { FlyControls } from 'three/examples/jsm/controls/FlyControls.js';
|
|
6
6
|
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
7
7
|
import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js';
|
|
8
8
|
import { parseToRgb, opacify } from 'polished';
|
|
9
|
-
import { Tween, Easing
|
|
9
|
+
import { Group, Tween, Easing } from '@tweenjs/tween.js';
|
|
10
10
|
import accessorFn from 'accessor-fn';
|
|
11
11
|
import Kapsule from 'kapsule';
|
|
12
12
|
import Tooltip from 'float-tooltip';
|
|
13
13
|
|
|
14
14
|
function styleInject(css, ref) {
|
|
15
|
-
if (ref ===
|
|
15
|
+
if (ref === void 0) ref = {};
|
|
16
16
|
var insertAt = ref.insertAt;
|
|
17
17
|
if (typeof document === 'undefined') {
|
|
18
18
|
return;
|
|
@@ -100,8 +100,8 @@ function _toConsumableArray(r) {
|
|
|
100
100
|
function _toPrimitive(t, r) {
|
|
101
101
|
if ("object" != typeof t || !t) return t;
|
|
102
102
|
var e = t[Symbol.toPrimitive];
|
|
103
|
-
if (
|
|
104
|
-
var i = e.call(t, r
|
|
103
|
+
if (void 0 !== e) {
|
|
104
|
+
var i = e.call(t, r);
|
|
105
105
|
if ("object" != typeof i) return i;
|
|
106
106
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
107
107
|
}
|
|
@@ -115,7 +115,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
115
115
|
if (r) {
|
|
116
116
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
117
117
|
var t = {}.toString.call(r).slice(8, -1);
|
|
118
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) :
|
|
118
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -135,10 +135,6 @@ var three = window.THREE ? window.THREE // Prefer consumption from global THREE,
|
|
|
135
135
|
SphereGeometry: SphereGeometry,
|
|
136
136
|
MeshBasicMaterial: MeshBasicMaterial,
|
|
137
137
|
BackSide: BackSide,
|
|
138
|
-
EventDispatcher: EventDispatcher,
|
|
139
|
-
MOUSE: MOUSE,
|
|
140
|
-
Quaternion: Quaternion,
|
|
141
|
-
Spherical: Spherical,
|
|
142
138
|
Clock: Clock
|
|
143
139
|
};
|
|
144
140
|
var threeRenderObjects = Kapsule({
|
|
@@ -155,6 +151,9 @@ var threeRenderObjects = Kapsule({
|
|
|
155
151
|
isNaN(height) && (state.height = prevHeight);
|
|
156
152
|
}
|
|
157
153
|
},
|
|
154
|
+
viewOffset: {
|
|
155
|
+
"default": [0, 0]
|
|
156
|
+
},
|
|
158
157
|
backgroundColor: {
|
|
159
158
|
"default": '#000011'
|
|
160
159
|
},
|
|
@@ -426,15 +425,15 @@ var threeRenderObjects = Kapsule({
|
|
|
426
425
|
init: function init(domNode, state) {
|
|
427
426
|
var _ref4 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
428
427
|
_ref4$controlType = _ref4.controlType,
|
|
429
|
-
controlType = _ref4$controlType ===
|
|
428
|
+
controlType = _ref4$controlType === void 0 ? 'trackball' : _ref4$controlType,
|
|
430
429
|
_ref4$useWebGPU = _ref4.useWebGPU,
|
|
431
|
-
useWebGPU = _ref4$useWebGPU ===
|
|
430
|
+
useWebGPU = _ref4$useWebGPU === void 0 ? false : _ref4$useWebGPU,
|
|
432
431
|
_ref4$rendererConfig = _ref4.rendererConfig,
|
|
433
|
-
rendererConfig = _ref4$rendererConfig ===
|
|
432
|
+
rendererConfig = _ref4$rendererConfig === void 0 ? {} : _ref4$rendererConfig,
|
|
434
433
|
_ref4$extraRenderers = _ref4.extraRenderers,
|
|
435
|
-
extraRenderers = _ref4$extraRenderers ===
|
|
434
|
+
extraRenderers = _ref4$extraRenderers === void 0 ? [] : _ref4$extraRenderers,
|
|
436
435
|
_ref4$waitForLoadComp = _ref4.waitForLoadComplete,
|
|
437
|
-
waitForLoadComplete = _ref4$waitForLoadComp ===
|
|
436
|
+
waitForLoadComplete = _ref4$waitForLoadComp === void 0 ? true : _ref4$waitForLoadComp;
|
|
438
437
|
// Wipe DOM
|
|
439
438
|
domNode.innerHTML = '';
|
|
440
439
|
|
|
@@ -583,14 +582,30 @@ var threeRenderObjects = Kapsule({
|
|
|
583
582
|
update: function update(state, changedProps) {
|
|
584
583
|
// resize canvas
|
|
585
584
|
if (state.width && state.height && (changedProps.hasOwnProperty('width') || changedProps.hasOwnProperty('height'))) {
|
|
586
|
-
|
|
587
|
-
|
|
585
|
+
var _state$camera;
|
|
586
|
+
var w = state.width;
|
|
587
|
+
var h = state.height;
|
|
588
|
+
state.container.style.width = "".concat(w, "px");
|
|
589
|
+
state.container.style.height = "".concat(h, "px");
|
|
588
590
|
[state.renderer, state.postProcessingComposer].concat(_toConsumableArray(state.extraRenderers)).forEach(function (r) {
|
|
589
|
-
return r.setSize(
|
|
591
|
+
return r.setSize(w, h);
|
|
590
592
|
});
|
|
591
|
-
state.camera.aspect =
|
|
593
|
+
state.camera.aspect = w / h;
|
|
594
|
+
var o = state.viewOffset.slice(0, 2);
|
|
595
|
+
o.some(function (n) {
|
|
596
|
+
return n;
|
|
597
|
+
}) && (_state$camera = state.camera).setViewOffset.apply(_state$camera, [w, h].concat(_toConsumableArray(o), [w, h]));
|
|
592
598
|
state.camera.updateProjectionMatrix();
|
|
593
599
|
}
|
|
600
|
+
if (changedProps.hasOwnProperty('viewOffset')) {
|
|
601
|
+
var _state$camera2;
|
|
602
|
+
var _w = state.width;
|
|
603
|
+
var _h = state.height;
|
|
604
|
+
var _o = state.viewOffset.slice(0, 2);
|
|
605
|
+
_o.some(function (n) {
|
|
606
|
+
return n;
|
|
607
|
+
}) ? (_state$camera2 = state.camera).setViewOffset.apply(_state$camera2, [_w, _h].concat(_toConsumableArray(_o), [_w, _h])) : state.camera.clearViewOffset();
|
|
608
|
+
}
|
|
594
609
|
if (changedProps.hasOwnProperty('skyRadius') && state.skyRadius) {
|
|
595
610
|
state.controls.hasOwnProperty('maxDistance') && changedProps.skyRadius && (state.controls.maxDistance = Math.min(state.controls.maxDistance, state.skyRadius));
|
|
596
611
|
state.camera.far = state.skyRadius * 2.5;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-render-objects",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.1",
|
|
4
4
|
"description": "Easy way to render ThreeJS objects with built-in interaction defaults",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -55,19 +55,19 @@
|
|
|
55
55
|
"three": ">=0.168"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/core": "^7.26.
|
|
59
|
-
"@babel/preset-env": "^7.26.
|
|
58
|
+
"@babel/core": "^7.26.9",
|
|
59
|
+
"@babel/preset-env": "^7.26.9",
|
|
60
60
|
"@rollup/plugin-babel": "^6.0.4",
|
|
61
61
|
"@rollup/plugin-commonjs": "^28.0.2",
|
|
62
62
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
63
63
|
"@rollup/plugin-terser": "^0.4.4",
|
|
64
|
-
"@types/react": "^19.0.
|
|
65
|
-
"postcss": "^8.5.
|
|
64
|
+
"@types/react": "^19.0.10",
|
|
65
|
+
"postcss": "^8.5.2",
|
|
66
66
|
"rimraf": "^6.0.1",
|
|
67
|
-
"rollup": "^4.
|
|
67
|
+
"rollup": "^4.34.8",
|
|
68
68
|
"rollup-plugin-dts": "^6.1.1",
|
|
69
69
|
"rollup-plugin-postcss": "^4.0.2",
|
|
70
|
-
"three": "^0.
|
|
70
|
+
"three": "^0.173.0",
|
|
71
71
|
"typescript": "^5.7.3"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|