three-render-objects 1.29.4 → 1.30.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/README.md +1 -0
- package/dist/three-render-objects.d.ts +1 -0
- package/dist/three-render-objects.js +53096 -1594
- package/dist/three-render-objects.js.map +1 -1
- package/dist/three-render-objects.min.js +2 -2
- package/dist/three-render-objects.mjs +60 -57
- package/package.json +12 -12
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import { WebGLRenderer, Scene, PerspectiveCamera, Raycaster, SRGBColorSpace, TextureLoader, Vector2, Vector3, Box3, Color, Mesh, SphereGeometry, MeshBasicMaterial, BackSide, EventDispatcher, MOUSE, Quaternion, Spherical, Clock } from 'three';
|
|
2
|
+
import { WebGPURenderer } from 'three/webgpu';
|
|
2
3
|
import { TrackballControls } from 'three/examples/jsm/controls/TrackballControls.js';
|
|
3
4
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
|
4
5
|
import { FlyControls } from 'three/examples/jsm/controls/FlyControls.js';
|
|
5
6
|
import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
6
7
|
import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js';
|
|
7
8
|
import { parseToRgb, opacify } from 'polished';
|
|
8
|
-
import
|
|
9
|
+
import { Tween, Easing, Group } from '@tweenjs/tween.js';
|
|
9
10
|
import accessorFn from 'accessor-fn';
|
|
10
11
|
import Kapsule from 'kapsule';
|
|
11
12
|
|
|
12
13
|
function styleInject(css, ref) {
|
|
13
|
-
ref = {};
|
|
14
|
-
ref.insertAt;
|
|
14
|
+
if (ref === void 0) ref = {};
|
|
15
|
+
var insertAt = ref.insertAt;
|
|
15
16
|
if (typeof document === 'undefined') {
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
19
|
var head = document.head || document.getElementsByTagName('head')[0];
|
|
19
20
|
var style = document.createElement('style');
|
|
20
21
|
style.type = 'text/css';
|
|
21
|
-
{
|
|
22
|
+
if (insertAt === 'top') {
|
|
23
|
+
if (head.firstChild) {
|
|
24
|
+
head.insertBefore(style, head.firstChild);
|
|
25
|
+
} else {
|
|
26
|
+
head.appendChild(style);
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
22
29
|
head.appendChild(style);
|
|
23
30
|
}
|
|
24
31
|
if (style.styleSheet) {
|
|
@@ -31,6 +38,28 @@ function styleInject(css, ref) {
|
|
|
31
38
|
var css_248z = ".scene-nav-info {\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n}\n\n.scene-tooltip {\n top: 0;\n color: lavender;\n font-size: 15px;\n}\n\n.scene-nav-info, .scene-tooltip {\n position: absolute;\n font-family: sans-serif;\n pointer-events: none;\n user-select: none;\n}\n\n.scene-container canvas:focus {\n outline: none;\n}";
|
|
32
39
|
styleInject(css_248z);
|
|
33
40
|
|
|
41
|
+
function _arrayLikeToArray(r, a) {
|
|
42
|
+
(null == a || a > r.length) && (a = r.length);
|
|
43
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
44
|
+
return n;
|
|
45
|
+
}
|
|
46
|
+
function _arrayWithHoles(r) {
|
|
47
|
+
if (Array.isArray(r)) return r;
|
|
48
|
+
}
|
|
49
|
+
function _arrayWithoutHoles(r) {
|
|
50
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
51
|
+
}
|
|
52
|
+
function _defineProperty(e, r, t) {
|
|
53
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
54
|
+
value: t,
|
|
55
|
+
enumerable: !0,
|
|
56
|
+
configurable: !0,
|
|
57
|
+
writable: !0
|
|
58
|
+
}) : e[r] = t, e;
|
|
59
|
+
}
|
|
60
|
+
function _iterableToArray(r) {
|
|
61
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
62
|
+
}
|
|
34
63
|
function _iterableToArrayLimit(r, l) {
|
|
35
64
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
36
65
|
if (null != t) {
|
|
@@ -55,67 +84,38 @@ function _iterableToArrayLimit(r, l) {
|
|
|
55
84
|
return a;
|
|
56
85
|
}
|
|
57
86
|
}
|
|
87
|
+
function _nonIterableRest() {
|
|
88
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
89
|
+
}
|
|
90
|
+
function _nonIterableSpread() {
|
|
91
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
92
|
+
}
|
|
93
|
+
function _slicedToArray(r, e) {
|
|
94
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
95
|
+
}
|
|
96
|
+
function _toConsumableArray(r) {
|
|
97
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
98
|
+
}
|
|
58
99
|
function _toPrimitive(t, r) {
|
|
59
100
|
if ("object" != typeof t || !t) return t;
|
|
60
101
|
var e = t[Symbol.toPrimitive];
|
|
61
102
|
if (void 0 !== e) {
|
|
62
|
-
var i = e.call(t, r );
|
|
103
|
+
var i = e.call(t, r || "default");
|
|
63
104
|
if ("object" != typeof i) return i;
|
|
64
105
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
65
106
|
}
|
|
66
|
-
return (String )(t);
|
|
107
|
+
return ("string" === r ? String : Number)(t);
|
|
67
108
|
}
|
|
68
109
|
function _toPropertyKey(t) {
|
|
69
110
|
var i = _toPrimitive(t, "string");
|
|
70
111
|
return "symbol" == typeof i ? i : i + "";
|
|
71
112
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
enumerable: true,
|
|
78
|
-
configurable: true,
|
|
79
|
-
writable: true
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
obj[key] = value;
|
|
113
|
+
function _unsupportedIterableToArray(r, a) {
|
|
114
|
+
if (r) {
|
|
115
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
116
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
117
|
+
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;
|
|
83
118
|
}
|
|
84
|
-
return obj;
|
|
85
|
-
}
|
|
86
|
-
function _slicedToArray(arr, i) {
|
|
87
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
88
|
-
}
|
|
89
|
-
function _toConsumableArray(arr) {
|
|
90
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
91
|
-
}
|
|
92
|
-
function _arrayWithoutHoles(arr) {
|
|
93
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
94
|
-
}
|
|
95
|
-
function _arrayWithHoles(arr) {
|
|
96
|
-
if (Array.isArray(arr)) return arr;
|
|
97
|
-
}
|
|
98
|
-
function _iterableToArray(iter) {
|
|
99
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
100
|
-
}
|
|
101
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
102
|
-
if (!o) return;
|
|
103
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
104
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
105
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
106
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
107
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
108
|
-
}
|
|
109
|
-
function _arrayLikeToArray(arr, len) {
|
|
110
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
111
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
112
|
-
return arr2;
|
|
113
|
-
}
|
|
114
|
-
function _nonIterableSpread() {
|
|
115
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
116
|
-
}
|
|
117
|
-
function _nonIterableRest() {
|
|
118
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
var three = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
|
|
@@ -250,7 +250,7 @@ var threeRenderObjects = Kapsule({
|
|
|
250
250
|
state.hoverObj = topObject;
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
|
|
253
|
+
state.tweenGroup.update(); // update camera animation tweens
|
|
254
254
|
}
|
|
255
255
|
return this;
|
|
256
256
|
},
|
|
@@ -281,10 +281,10 @@ var threeRenderObjects = Kapsule({
|
|
|
281
281
|
} else {
|
|
282
282
|
var camPos = Object.assign({}, camera.position);
|
|
283
283
|
var camLookAt = getLookAt();
|
|
284
|
-
new
|
|
284
|
+
state.tweenGroup.add(new Tween(camPos).to(finalPos, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(setCameraPos).start());
|
|
285
285
|
|
|
286
286
|
// Face direction in 1/3rd of time
|
|
287
|
-
new
|
|
287
|
+
state.tweenGroup.add(new Tween(camLookAt).to(finalLookAt, transitionDuration / 3).easing(Easing.Quadratic.Out).onUpdate(setLookAt).start());
|
|
288
288
|
}
|
|
289
289
|
return this;
|
|
290
290
|
}
|
|
@@ -415,13 +415,16 @@ var threeRenderObjects = Kapsule({
|
|
|
415
415
|
return {
|
|
416
416
|
scene: new three.Scene(),
|
|
417
417
|
camera: new three.PerspectiveCamera(),
|
|
418
|
-
clock: new three.Clock()
|
|
418
|
+
clock: new three.Clock(),
|
|
419
|
+
tweenGroup: new Group()
|
|
419
420
|
};
|
|
420
421
|
},
|
|
421
422
|
init: function init(domNode, state) {
|
|
422
423
|
var _ref4 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
423
424
|
_ref4$controlType = _ref4.controlType,
|
|
424
425
|
controlType = _ref4$controlType === void 0 ? 'trackball' : _ref4$controlType,
|
|
426
|
+
_ref4$useWebGPU = _ref4.useWebGPU,
|
|
427
|
+
useWebGPU = _ref4$useWebGPU === void 0 ? false : _ref4$useWebGPU,
|
|
425
428
|
_ref4$rendererConfig = _ref4.rendererConfig,
|
|
426
429
|
rendererConfig = _ref4$rendererConfig === void 0 ? {} : _ref4$rendererConfig,
|
|
427
430
|
_ref4$extraRenderers = _ref4.extraRenderers,
|
|
@@ -522,7 +525,7 @@ var threeRenderObjects = Kapsule({
|
|
|
522
525
|
});
|
|
523
526
|
|
|
524
527
|
// Setup renderer, camera and controls
|
|
525
|
-
state.renderer = new three.WebGLRenderer(Object.assign({
|
|
528
|
+
state.renderer = new (useWebGPU ? WebGPURenderer : three.WebGLRenderer)(Object.assign({
|
|
526
529
|
antialias: true,
|
|
527
530
|
alpha: true
|
|
528
531
|
}, rendererConfig));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-render-objects",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
4
4
|
"description": "Easy way to render ThreeJS objects with built-in interaction defaults",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"prepare": "npm run build"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@tweenjs/tween.js": "18 -
|
|
48
|
+
"@tweenjs/tween.js": "18 - 25",
|
|
49
49
|
"accessor-fn": "1",
|
|
50
50
|
"kapsule": "1",
|
|
51
51
|
"polished": "4"
|
|
@@ -54,19 +54,19 @@
|
|
|
54
54
|
"three": "*"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@babel/core": "^7.
|
|
58
|
-
"@babel/preset-env": "^7.
|
|
57
|
+
"@babel/core": "^7.25.8",
|
|
58
|
+
"@babel/preset-env": "^7.25.8",
|
|
59
59
|
"@rollup/plugin-babel": "^6.0.4",
|
|
60
|
-
"@rollup/plugin-commonjs": "^
|
|
61
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
60
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
61
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
62
62
|
"@rollup/plugin-terser": "^0.4.4",
|
|
63
|
-
"postcss": "^8.4.
|
|
64
|
-
"rimraf": "^
|
|
65
|
-
"rollup": "^4.
|
|
66
|
-
"rollup-plugin-dts": "^6.1.
|
|
63
|
+
"postcss": "^8.4.47",
|
|
64
|
+
"rimraf": "^6.0.1",
|
|
65
|
+
"rollup": "^4.24.0",
|
|
66
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
67
67
|
"rollup-plugin-postcss": "^4.0.2",
|
|
68
|
-
"three": "^0.
|
|
69
|
-
"typescript": "^5.
|
|
68
|
+
"three": "^0.169.0",
|
|
69
|
+
"typescript": "^5.6.3"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
72
|
"node": ">=12"
|