@shopware-ag/dive 2.2.34 → 2.3.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.
- package/build/chunks/Animator-BGFdF70Z.mjs +47 -0
- package/build/chunks/Animator-Cu7NIkVg.cjs +1 -0
- package/build/chunks/{AssetCache-lGp7KKQA.mjs → AssetCache-BN-AmXc9.mjs} +1 -1
- package/build/chunks/{AssetCache-BOMaDRGn.cjs → AssetCache-CwK-0iP9.cjs} +1 -1
- package/build/chunks/{AssetExporter-brT7ogoM.mjs → AssetExporter-BBaDvZ8D.mjs} +68 -61
- package/build/chunks/{AssetExporter-DsbC2rqv.cjs → AssetExporter-Bqv27MWV.cjs} +15 -15
- package/build/chunks/{AssetLoader-BDP2bROu.mjs → AssetLoader-C-PfRr8Z.mjs} +20 -12
- package/build/chunks/{AssetLoader-B00ge8um.cjs → AssetLoader-uFMzuJWt.cjs} +2 -2
- package/build/chunks/ClipAnimator-BJZ4_C4B.mjs +83 -0
- package/build/chunks/ClipAnimator-CNKeT7rW.cjs +1 -0
- package/build/chunks/{FileTypes-DeUmmPCi.mjs → FileTypes-B8g1qxjR.mjs} +41 -38
- package/build/chunks/{FileTypes-DOUQk-mF.cjs → FileTypes-BHH0KUFf.cjs} +2 -2
- package/build/chunks/TargetAnimator-DUqkkdVb.mjs +79 -0
- package/build/chunks/TargetAnimator-DuqPk2eq.cjs +1 -0
- package/build/chunks/{isFileTypeSupported-D8QKkffJ.cjs → isFileTypeSupported-CFN9V48s.cjs} +1 -1
- package/build/chunks/{isFileTypeSupported-DsYDdT2J.mjs → isFileTypeSupported-DA7cjOZa.mjs} +1 -1
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +2 -2
- package/build/plugins/animation/index.cjs +1 -1
- package/build/plugins/animation/index.d.ts +1 -1
- package/build/plugins/animation/index.mjs +84 -109
- package/build/plugins/animation/src/animator/Animator.d.ts +23 -22
- package/build/plugins/animation/src/animator/ClipAnimator.d.ts +33 -0
- package/build/plugins/animation/src/animator/TargetAnimator.d.ts +45 -0
- package/build/plugins/animation/src/index.d.ts +4 -2
- package/build/plugins/animation/src/system/AnimationSystem.d.ts +136 -14
- package/build/plugins/animation/src/types/AnimatorTypes.d.ts +11 -0
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +2 -2
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetexporter/index.cjs +1 -1
- package/build/plugins/assetexporter/index.mjs +1 -1
- package/build/plugins/assetexporter/src/AssetExporter.d.ts +1 -0
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +2 -2
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +1 -1
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +7 -7
- package/build/plugins/quickview/src/QuickView.d.ts +2 -1
- package/build/plugins/state/index.cjs +4 -4
- package/build/plugins/state/index.mjs +791 -794
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +1 -1
- package/package.json +2 -2
- package/build/plugins/animation/src/types/AnimatorParameters.d.ts +0 -7
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var d = (n, o, t) => o in n ? c(n, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[o] = t;
|
|
3
|
+
var s = (n, o, t) => d(n, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
+
import { Group as l, Tween as g, Easing as f } from "@tweenjs/tween.js";
|
|
5
|
+
import { A as y } from "./Animator-BGFdF70Z.mjs";
|
|
6
|
+
class v extends y {
|
|
7
|
+
constructor(t, i, h) {
|
|
8
|
+
super();
|
|
9
|
+
s(this, "_group", new l());
|
|
10
|
+
s(this, "_tweens", []);
|
|
11
|
+
s(this, "_snapshots", []);
|
|
12
|
+
s(this, "_state", "idle");
|
|
13
|
+
s(this, "_duration");
|
|
14
|
+
s(this, "_loop", "once");
|
|
15
|
+
s(this, "_options");
|
|
16
|
+
s(this, "_completedCount", 0);
|
|
17
|
+
this._duration = i, this._options = h;
|
|
18
|
+
const _ = Array.isArray(t) ? t : [t];
|
|
19
|
+
for (const r of _) {
|
|
20
|
+
const p = {};
|
|
21
|
+
for (const e of Object.keys(r.to))
|
|
22
|
+
p[e] = r.object[e];
|
|
23
|
+
this._snapshots.push({ object: r.object, values: p });
|
|
24
|
+
const u = new g(r.object, this._group).to(r.to, i).easing((h == null ? void 0 : h.easing) ?? f.Quadratic.Out).onUpdate(() => {
|
|
25
|
+
var e, a;
|
|
26
|
+
(a = (e = this._options) == null ? void 0 : e.onUpdate) == null || a.call(e), this.dispatchEvent({ type: "update", target: this });
|
|
27
|
+
}).onComplete(() => {
|
|
28
|
+
var e, a;
|
|
29
|
+
this._completedCount++, this._completedCount >= this._tweens.length && (this._state = "idle", (a = (e = this._options) == null ? void 0 : e.onComplete) == null || a.call(e), this.dispatchEvent({ type: "complete", target: this }));
|
|
30
|
+
});
|
|
31
|
+
this._tweens.push(u);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
get state() {
|
|
35
|
+
return this._state;
|
|
36
|
+
}
|
|
37
|
+
get duration() {
|
|
38
|
+
return this._duration;
|
|
39
|
+
}
|
|
40
|
+
get loop() {
|
|
41
|
+
return this._loop;
|
|
42
|
+
}
|
|
43
|
+
set loop(t) {
|
|
44
|
+
this._loop = t, this._tweens.forEach((i) => {
|
|
45
|
+
i.repeat(t === "once" ? 0 : 1 / 0), i.yoyo(t === "pingpong");
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
get time() {
|
|
49
|
+
return this._tweens.length > 0 ? this._tweens[0].getDuration() : 0;
|
|
50
|
+
}
|
|
51
|
+
set time(t) {
|
|
52
|
+
}
|
|
53
|
+
play() {
|
|
54
|
+
return this._tweens.forEach((t) => t.stop()), this._state = "playing", this._completedCount = 0, this._restoreSnapshots(), this._tweens.forEach((t) => t.start()), this.dispatchEvent({ type: "play", target: this }), this;
|
|
55
|
+
}
|
|
56
|
+
pause() {
|
|
57
|
+
return this._state = "paused", this._tweens.forEach((t) => t.pause()), this.dispatchEvent({ type: "pause", target: this }), this;
|
|
58
|
+
}
|
|
59
|
+
resume() {
|
|
60
|
+
return this._state = "playing", this._tweens.forEach((t) => t.resume()), this.dispatchEvent({ type: "resume", target: this }), this;
|
|
61
|
+
}
|
|
62
|
+
stop() {
|
|
63
|
+
return this._state = "idle", this._tweens.forEach((t) => t.stop()), this._restoreSnapshots(), this.dispatchEvent({ type: "stop", target: this }), this;
|
|
64
|
+
}
|
|
65
|
+
update() {
|
|
66
|
+
this._state !== "idle" && this._group.update();
|
|
67
|
+
}
|
|
68
|
+
_restoreSnapshots() {
|
|
69
|
+
for (const { object: t, values: i } of this._snapshots)
|
|
70
|
+
for (const h of Object.keys(i))
|
|
71
|
+
t[h] = i[h];
|
|
72
|
+
}
|
|
73
|
+
dispose() {
|
|
74
|
+
this._tweens.forEach((t) => t.stop()), this._tweens = [], this._group.removeAll(), this._state = "idle";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
v as TargetAnimator
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var d=(r,o,t)=>o in r?l(r,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[o]=t;var s=(r,o,t)=>d(r,typeof o!="symbol"?o+"":o,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@tweenjs/tween.js"),g=require("./Animator-Cu7NIkVg.cjs");class y extends g.Animator{constructor(t,i,n){super();s(this,"_group",new p.Group);s(this,"_tweens",[]);s(this,"_snapshots",[]);s(this,"_state","idle");s(this,"_duration");s(this,"_loop","once");s(this,"_options");s(this,"_completedCount",0);this._duration=i,this._options=n;const u=Array.isArray(t)?t:[t];for(const h of u){const _={};for(const e of Object.keys(h.to))_[e]=h.object[e];this._snapshots.push({object:h.object,values:_});const c=new p.Tween(h.object,this._group).to(h.to,i).easing((n==null?void 0:n.easing)??p.Easing.Quadratic.Out).onUpdate(()=>{var e,a;(a=(e=this._options)==null?void 0:e.onUpdate)==null||a.call(e),this.dispatchEvent({type:"update",target:this})}).onComplete(()=>{var e,a;this._completedCount++,this._completedCount>=this._tweens.length&&(this._state="idle",(a=(e=this._options)==null?void 0:e.onComplete)==null||a.call(e),this.dispatchEvent({type:"complete",target:this}))});this._tweens.push(c)}}get state(){return this._state}get duration(){return this._duration}get loop(){return this._loop}set loop(t){this._loop=t,this._tweens.forEach(i=>{i.repeat(t==="once"?0:1/0),i.yoyo(t==="pingpong")})}get time(){return this._tweens.length>0?this._tweens[0].getDuration():0}set time(t){}play(){return this._tweens.forEach(t=>t.stop()),this._state="playing",this._completedCount=0,this._restoreSnapshots(),this._tweens.forEach(t=>t.start()),this.dispatchEvent({type:"play",target:this}),this}pause(){return this._state="paused",this._tweens.forEach(t=>t.pause()),this.dispatchEvent({type:"pause",target:this}),this}resume(){return this._state="playing",this._tweens.forEach(t=>t.resume()),this.dispatchEvent({type:"resume",target:this}),this}stop(){return this._state="idle",this._tweens.forEach(t=>t.stop()),this._restoreSnapshots(),this.dispatchEvent({type:"stop",target:this}),this}update(){this._state!=="idle"&&this._group.update()}_restoreSnapshots(){for(const{object:t,values:i}of this._snapshots)for(const n of Object.keys(i))t[n]=i[n]}dispose(){this._tweens.forEach(t=>t.stop()),this._tweens=[],this._group.removeAll(),this._state="idle"}}exports.TargetAnimator=y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./FileTypes-
|
|
1
|
+
"use strict";const n=require("./FileTypes-BHH0KUFf.cjs");function o(e){var t;const i=e.split("/").pop()||"";return!i.includes(".")||i.endsWith(".")?"":((t=i.split(".").pop())==null?void 0:t.toLowerCase().split("?")[0])||""}function r(e){return e.toLowerCase()in n.FILE_TYPES}exports.getFileTypeFromUri=o;exports.isFileTypeSupported=r;
|
package/build/dive.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty;var R=(r,i,e)=>i in r?b(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>R(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./chunks/FileTypes-DOUQk-mF.cjs"),u=require("./chunks/PerspectiveCamera-iAsZqrnY.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three"),V=require("./chunks/findInterface-C6mrvf_t.cjs"),y=require("./chunks/isFileTypeSupported-D8QKkffJ.cjs"),w=require("./chunks/network-error-CdDXil5g.cjs"),A=require("./chunks/parse-error-Dy_EE4rL.cjs"),P=require("./chunks/PovSchema-Co9FznEz.cjs");class m extends s.Object3D{constructor(e,t,o,h,a){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVERadialHandle",this.axis=e,this._color.set(a),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1;const l=new s.TorusGeometry(t,.01,13,48,o);this._lineMaterial=new s.MeshBasicMaterial({color:a,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,this.add(d);const g=new s.TorusGeometry(t,.1,3,48,o),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this.add(this._colliderMesh),this.lookAt(h)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}function p(r,i){const e=(r+"e").split("e");return+(e[0]+"e"+(+e[1]+(i||0)))}function O(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function v(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function x(r,i=0){if(r<0)return-x(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function H(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function z(r,i=0){const e=p(r,+i);return p(Math.round(e),-i).toFixed(i)}function G(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function C(r){return(s.MathUtils.radToDeg(r)+360)%360}function L(r){return s.MathUtils.degToRad(r)}const S={ceilExp:O,floorExp:v,roundExp:x,toFixedExp:z,truncateExp:G,signedAngleTo:H,radToDeg:C,degToRad:L};class T extends s.Object3D{constructor(e){super();n(this,"children");n(this,"_controller");n(this,"_startRot");this.name="DIVERotateGizmo",this.children=[],this._startRot=null,this._controller=e,this.add(new m("x",1,Math.PI/2,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new m("y",1,-Math.PI/2,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new m("z",1,Math.PI/2,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startRot||this.parent&&this.parent.parent&&(this.parent.parent.onHover("rotate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startRot=t.rotation.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startRot||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragCurrent.clone().sub(this.parent.parent.position).normalize(),h=t.dragStart.clone().sub(this.parent.parent.position).normalize(),a=S.signedAngleTo(h,o,e.forwardVector),l=new s.Euler(this._startRot.x+e.forwardVector.x*a,this._startRot.y+e.forwardVector.y*a,this._startRot.z+e.forwardVector.z*a);this.parent.parent.onChange(void 0,l)}onHandleDragEnd(e){this._startRot=null,this.handleHighlight(e.axis,!1,!1)}}class D extends s.Object3D{constructor(e,t,o,h){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVEAxisHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._highlight=!1,this._hovered=!1;const a=new s.CylinderGeometry(.01,.01,t,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const l=new s.Mesh(a,this._lineMaterial);l.layers.mask=u.UI_LAYER_MASK,l.renderOrder=1/0,l.rotateX(Math.PI/2),l.translateY(t/2),this.add(l);const d=new s.CylinderGeometry(.1,.1,t,3),g=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(d,g),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}class Y extends s.Object3D{constructor(e){super();n(this,"_controller");n(this,"children");n(this,"_startPos");this.name="DIVETranslateGizmo",this.children=[],this._startPos=null,this._controller=e,this.add(new D("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new D("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new D("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startPos||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startPos=t.position.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startPos||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(this._startPos.clone().add(o))}onHandleDragEnd(e){this._startPos=null,this.handleHighlight(e.axis,!1,!1)}}class M extends s.Object3D{constructor(e,t,o,h,a=.05){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");n(this,"_box");n(this,"_boxSize");this.name="DIVEScaleHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1,this._boxSize=a;const l=new s.CylinderGeometry(.01,.01,t-a/2,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,d.rotateX(Math.PI/2),d.translateY(t/2-a/4),this.add(d),this._box=new s.Mesh(new s.BoxGeometry(a,a,a),this._lineMaterial),this._box.layers.mask=u.UI_LAYER_MASK,this._box.renderOrder=1/0,this._box.rotateX(Math.PI/2),this._box.translateY(t-a/2),this._box.rotateZ(o.x*Math.PI/2),this._box.rotateX(o.z*Math.PI/2),this.add(this._box);const g=new s.CylinderGeometry(.1,.1,t+a/2,3),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}update(e){this._box.scale.copy(new s.Vector3(1,1,1).sub(this.forwardVector).add(e.clone().multiply(this.forwardVector)))}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHoverAxis(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHoverAxis(this,!1)}onDragStart(){this.parent&&this.parent.onAxisDragStart(this)}onDrag(e){this.parent&&this.parent.onAxisDrag(this,e)}onDragEnd(){this.parent&&this.parent.onAxisDragEnd(this)}}class j extends s.Object3D{constructor(e){super();n(this,"isHoverable",!0);n(this,"children");n(this,"_controller");n(this,"_startScale");this.name="DIVEScaleGizmo",this.children=[],this._startScale=null,this._controller=e,this.add(new M("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new M("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new M("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}update(e){this.children.forEach(t=>{t.update(e)})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHoverAxis(e,t){this._startScale||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onAxisDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startScale=t.scale.clone(),this.handleHighlight(e.axis,!0,!0))}onAxisDrag(e,t){if(!this._startScale||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(void 0,void 0,this._startScale.clone().add(o))}onAxisDragEnd(e){this._startScale=null,this.handleHighlight(e.axis,!1,!1)}}class N extends s.Object3D{constructor(){super();n(this,"_meshX");n(this,"_meshY");n(this,"_meshZ");this.name="DIVEGizmoPlane";const e=new s.MeshBasicMaterial({transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1,side:2}),t=new s.PlaneGeometry(100,100,2,2),o=e.clone();o.color.set(16711680),this._meshX=new s.Mesh(t,o),this._meshX.layers.mask=u.UI_LAYER_MASK,this._meshX.rotateY(Math.PI/2);const h=new s.PlaneGeometry(100,100,2,2),a=e.clone();a.color.set(65280),this._meshY=new s.Mesh(h,a),this._meshY.layers.mask=u.UI_LAYER_MASK,this._meshY.rotateX(-Math.PI/2);const l=new s.PlaneGeometry(100,100,2,2),d=e.clone();d.color.set(255),this._meshZ=new s.Mesh(l,d),this._meshZ.layers.mask=u.UI_LAYER_MASK}get XPlane(){return this._meshX}get YPlane(){return this._meshY}get ZPlane(){return this._meshZ}assemble(e,t){if(this.clear(),e==="translate"||e==="scale")switch(t){case"x":this.add(this._meshY),this.add(this._meshZ);break;case"y":this.add(this._meshX),this.add(this._meshZ);break;case"z":this.add(this._meshX),this.add(this._meshY);break}else if(e==="rotate")switch(t){case"x":this.add(this._meshX);break;case"y":this.add(this._meshY);break;case"z":this.add(this._meshZ);break}}}class F extends s.Object3D{constructor(e){super();n(this,"_mode");n(this,"_gizmoNode");n(this,"_translateGizmo");n(this,"_rotateGizmo");n(this,"_scaleGizmo");n(this,"_gizmoPlane");n(this,"_object");this.name="DIVEGizmo",e.addEventListener("change",()=>{const t=e.getDistance()/2.5;this.scale.set(t,t,t)}),this._mode="translate",this._gizmoNode=new s.Object3D,this.add(this._gizmoNode),this._translateGizmo=new Y(e),this._rotateGizmo=new T(e),this._scaleGizmo=new j(e),this._gizmoPlane=new N,this._gizmoPlane.visible=!1,this._object=null}get mode(){return this._mode}set mode(e){this._mode=e,this.assemble()}set debug(e){this._translateGizmo.debug=e,this._rotateGizmo.debug=e,this._scaleGizmo.debug=e}get gizmoNode(){return this._gizmoNode}get gizmoPlane(){return this._gizmoPlane}get object(){return this._object}attach(e){return this._object=e,this.assemble(),this}detach(){return this._object=null,this.assemble(),this}onHover(e,t,o){o&&this._gizmoPlane.assemble(e,t)}onChange(e,t,o){this.object!==null&&(e&&(this.position.copy(e),this.object.position.copy(e)),t&&this.object.rotation.copy(t),o&&(this.object.scale.copy(o),this._scaleGizmo.update(o)))}assemble(){this._gizmoNode.clear(),this._gizmoPlane.clear(),this._translateGizmo.reset(),this._rotateGizmo.reset(),this._scaleGizmo.reset(),this.object!==null&&(this._mode==="translate"&&this._gizmoNode.add(this._translateGizmo),this._mode==="rotate"&&this._gizmoNode.add(this._rotateGizmo),this._mode==="scale"&&this._gizmoNode.add(this._scaleGizmo),this.add(this._gizmoPlane))}}class U{constructor(){n(this,"isMovable",!0)}}class K{constructor(){n(this,"isSelectable",!0)}}function X(r,i){return i.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(o=>{if(o==="constructor")return;const h=Object.getOwnPropertyDescriptor(e.prototype,o);Object.defineProperty(r.prototype,o,h)});const t=new e;Object.getOwnPropertyNames(t).forEach(o=>{const h=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r.prototype,o,h)})}),r}function f(r,i=new WeakMap){if(r===null||typeof r!="object")return r;if(i.has(r))return i.get(r);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const a=[];i.set(r,a);for(let l=0;l<r.length;l++)a[l]=f(r[l],i);return a}if(r instanceof Map){const a=new Map;i.set(r,a);for(const[l,d]of r)a.set(f(l,i),f(d,i));return a}if(r instanceof Set){const a=new Set;i.set(r,a);for(const l of r)a.add(f(l,i));return a}const e=r;if(typeof e.clone=="function"){const a=e.clone();return i.set(r,a),a}const t=Object.create(Object.getPrototypeOf(r));i.set(r,t);const o=Object.getOwnPropertyNames(r);for(const a of o){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}const h=Object.getOwnPropertySymbols(r);for(const a of h){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}return t}const I=(r,i)=>{if(Object.keys(r).length===0&&Object.keys(i).length===0)return{};if(typeof r!="object"||typeof i!="object")return i;let e={};return Object.keys(i).forEach(t=>{if(!Object.keys(r).includes(t)){e={...e,[t]:i[t]};return}if(Array.isArray(i[t])){if(!Array.isArray(r[t])){e={...e,[t]:i[t]};return}const o=r[t],h=i[t];if(o.length===0&&h.length===0){e={...e};return}if(o.length!==h.length){e={...e,[t]:i[t]};return}const a=[];if(h.forEach((l,d)=>{const g=I(o[d],h[d]);Object.keys(g).length&&a.push(h[d])}),Object.keys(a).length){e={...e,[t]:a};return}return}if(typeof i[t]=="object"){if(typeof r[t]!="object"){e={...e,[t]:i[t]};return}const o=I(r[t],i[t]);if(Object.keys(o).length){e={...e,[t]:o};return}}r[t]!==i[t]&&(e={...e,[t]:i[t]})}),e};function q(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function Z(r){return r.entityType==="primitive"}exports.BoundingBox=c.BoundingBox;exports.DIVE=c.DIVE;exports.DIVEAmbientLight=c.DIVEAmbientLight;exports.DIVEClock=c.DIVEClock;exports.DIVEDefaultSettings=c.DIVEDefaultSettings;exports.DIVEEngine=c.DIVEEngine;exports.DIVEEnvironment=c.DIVEEnvironment;exports.DIVEEnvironmentDefaultSettings=c.DIVEEnvironmentDefaultSettings;exports.DIVEFloor=c.DIVEFloor;exports.DIVEGrid=c.DIVEGrid;exports.DIVEGroup=c.DIVEGroup;exports.DIVEModel=c.DIVEModel;exports.DIVENode=c.DIVENode;exports.DIVEPointLight=c.DIVEPointLight;exports.DIVEPrimitive=c.DIVEPrimitive;exports.DIVERenderPipeline=c.DIVERenderPipeline;exports.DIVERenderer=c.DIVERenderer;exports.DIVERendererDefaultSettings=c.DIVERendererDefaultSettings;exports.DIVEResizeManager=c.DIVEResizeManager;exports.DIVERoot=c.DIVERoot;exports.DIVEScene=c.DIVEScene;exports.DIVESceneDefaultSettings=c.DIVESceneDefaultSettings;exports.DIVESceneLight=c.DIVESceneLight;exports.DIVEView=c.DIVEView;exports.FILE_TYPES=c.FILE_TYPES;exports.GRID_CENTER_LINE_COLOR=c.GRID_CENTER_LINE_COLOR;exports.GRID_SIDE_LINE_COLOR=c.GRID_SIDE_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=c.SUPPORTED_FILE_TYPES;exports.findSceneRecursive=c.findSceneRecursive;exports.COORDINATE_LAYER_MASK=u.COORDINATE_LAYER_MASK;exports.DEFAULT_LAYER_MASK=u.DEFAULT_LAYER_MASK;exports.DIVEPerspectiveCamera=u.DIVEPerspectiveCamera;exports.DIVEPerspectiveCameraDefaultSettings=u.DIVEPerspectiveCameraDefaultSettings;exports.HELPER_LAYER_MASK=u.HELPER_LAYER_MASK;exports.PRODUCT_LAYER_MASK=u.PRODUCT_LAYER_MASK;exports.UI_LAYER_MASK=u.UI_LAYER_MASK;exports.AxesColorBlue=_.AxesColorBlue;exports.AxesColorBlueLetter=_.AxesColorBlueLetter;exports.AxesColorGreen=_.AxesColorGreen;exports.AxesColorGreenLetter=_.AxesColorGreenLetter;exports.AxesColorRed=_.AxesColorRed;exports.AxesColorRedLetter=_.AxesColorRedLetter;exports.findInterface=V.findInterface;exports.implementsInterface=V.implementsInterface;exports.getFileTypeFromUri=y.getFileTypeFromUri;exports.isFileTypeSupported=y.isFileTypeSupported;exports.FileContentError=w.FileContentError;exports.NetworkError=w.NetworkError;exports.FileTypeError=A.FileTypeError;exports.ParseError=A.ParseError;exports.isModelSchema=P.isModelSchema;exports.isPovSchema=P.isPovSchema;exports.DIVEGizmo=F;exports.DIVEMath=S;exports.DIVEMovable=U;exports.DIVESelectable=K;exports.applyMixins=X;exports.deepClone=f;exports.getObjectDelta=I;exports.isGroupSchema=q;exports.isLightSchema=B;exports.isPrimitiveSchema=Z;
|
|
1
|
+
"use strict";var b=Object.defineProperty;var R=(r,i,e)=>i in r?b(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>R(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./chunks/FileTypes-BHH0KUFf.cjs"),u=require("./chunks/PerspectiveCamera-iAsZqrnY.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three"),V=require("./chunks/findInterface-C6mrvf_t.cjs"),y=require("./chunks/isFileTypeSupported-CFN9V48s.cjs"),w=require("./chunks/network-error-CdDXil5g.cjs"),A=require("./chunks/parse-error-Dy_EE4rL.cjs"),P=require("./chunks/PovSchema-Co9FznEz.cjs");class m extends s.Object3D{constructor(e,t,o,h,a){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVERadialHandle",this.axis=e,this._color.set(a),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1;const l=new s.TorusGeometry(t,.01,13,48,o);this._lineMaterial=new s.MeshBasicMaterial({color:a,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,this.add(d);const g=new s.TorusGeometry(t,.1,3,48,o),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this.add(this._colliderMesh),this.lookAt(h)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}function p(r,i){const e=(r+"e").split("e");return+(e[0]+"e"+(+e[1]+(i||0)))}function O(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function v(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function x(r,i=0){if(r<0)return-x(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function H(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function z(r,i=0){const e=p(r,+i);return p(Math.round(e),-i).toFixed(i)}function G(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function C(r){return(s.MathUtils.radToDeg(r)+360)%360}function L(r){return s.MathUtils.degToRad(r)}const S={ceilExp:O,floorExp:v,roundExp:x,toFixedExp:z,truncateExp:G,signedAngleTo:H,radToDeg:C,degToRad:L};class T extends s.Object3D{constructor(e){super();n(this,"children");n(this,"_controller");n(this,"_startRot");this.name="DIVERotateGizmo",this.children=[],this._startRot=null,this._controller=e,this.add(new m("x",1,Math.PI/2,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new m("y",1,-Math.PI/2,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new m("z",1,Math.PI/2,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startRot||this.parent&&this.parent.parent&&(this.parent.parent.onHover("rotate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startRot=t.rotation.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startRot||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragCurrent.clone().sub(this.parent.parent.position).normalize(),h=t.dragStart.clone().sub(this.parent.parent.position).normalize(),a=S.signedAngleTo(h,o,e.forwardVector),l=new s.Euler(this._startRot.x+e.forwardVector.x*a,this._startRot.y+e.forwardVector.y*a,this._startRot.z+e.forwardVector.z*a);this.parent.parent.onChange(void 0,l)}onHandleDragEnd(e){this._startRot=null,this.handleHighlight(e.axis,!1,!1)}}class D extends s.Object3D{constructor(e,t,o,h){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVEAxisHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._highlight=!1,this._hovered=!1;const a=new s.CylinderGeometry(.01,.01,t,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const l=new s.Mesh(a,this._lineMaterial);l.layers.mask=u.UI_LAYER_MASK,l.renderOrder=1/0,l.rotateX(Math.PI/2),l.translateY(t/2),this.add(l);const d=new s.CylinderGeometry(.1,.1,t,3),g=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(d,g),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}class Y extends s.Object3D{constructor(e){super();n(this,"_controller");n(this,"children");n(this,"_startPos");this.name="DIVETranslateGizmo",this.children=[],this._startPos=null,this._controller=e,this.add(new D("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new D("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new D("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHandleHover(e,t){this._startPos||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startPos=t.position.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startPos||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(this._startPos.clone().add(o))}onHandleDragEnd(e){this._startPos=null,this.handleHighlight(e.axis,!1,!1)}}class M extends s.Object3D{constructor(e,t,o,h,a=.05){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");n(this,"_box");n(this,"_boxSize");this.name="DIVEScaleHandle",this.axis=e,this._color.set(h),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1,this._boxSize=a;const l=new s.CylinderGeometry(.01,.01,t-a/2,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,d.rotateX(Math.PI/2),d.translateY(t/2-a/4),this.add(d),this._box=new s.Mesh(new s.BoxGeometry(a,a,a),this._lineMaterial),this._box.layers.mask=u.UI_LAYER_MASK,this._box.renderOrder=1/0,this._box.rotateX(Math.PI/2),this._box.translateY(t-a/2),this._box.rotateZ(o.x*Math.PI/2),this._box.rotateX(o.z*Math.PI/2),this.add(this._box);const g=new s.CylinderGeometry(.1,.1,t+a/2,3),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}update(e){this._box.scale.copy(new s.Vector3(1,1,1).sub(this.forwardVector).add(e.clone().multiply(this.forwardVector)))}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHoverAxis(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHoverAxis(this,!1)}onDragStart(){this.parent&&this.parent.onAxisDragStart(this)}onDrag(e){this.parent&&this.parent.onAxisDrag(this,e)}onDragEnd(){this.parent&&this.parent.onAxisDragEnd(this)}}class j extends s.Object3D{constructor(e){super();n(this,"isHoverable",!0);n(this,"children");n(this,"_controller");n(this,"_startScale");this.name="DIVEScaleGizmo",this.children=[],this._startScale=null,this._controller=e,this.add(new M("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new M("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new M("z",1,new s.Vector3(0,0,1),_.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}update(e){this.children.forEach(t=>{t.update(e)})}handleHighlight(e,t,o){this.children.forEach(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.axis===e&&t})}onHoverAxis(e,t){this._startScale||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onAxisDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startScale=t.scale.clone(),this.handleHighlight(e.axis,!0,!0))}onAxisDrag(e,t){if(!this._startScale||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(void 0,void 0,this._startScale.clone().add(o))}onAxisDragEnd(e){this._startScale=null,this.handleHighlight(e.axis,!1,!1)}}class N extends s.Object3D{constructor(){super();n(this,"_meshX");n(this,"_meshY");n(this,"_meshZ");this.name="DIVEGizmoPlane";const e=new s.MeshBasicMaterial({transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1,side:2}),t=new s.PlaneGeometry(100,100,2,2),o=e.clone();o.color.set(16711680),this._meshX=new s.Mesh(t,o),this._meshX.layers.mask=u.UI_LAYER_MASK,this._meshX.rotateY(Math.PI/2);const h=new s.PlaneGeometry(100,100,2,2),a=e.clone();a.color.set(65280),this._meshY=new s.Mesh(h,a),this._meshY.layers.mask=u.UI_LAYER_MASK,this._meshY.rotateX(-Math.PI/2);const l=new s.PlaneGeometry(100,100,2,2),d=e.clone();d.color.set(255),this._meshZ=new s.Mesh(l,d),this._meshZ.layers.mask=u.UI_LAYER_MASK}get XPlane(){return this._meshX}get YPlane(){return this._meshY}get ZPlane(){return this._meshZ}assemble(e,t){if(this.clear(),e==="translate"||e==="scale")switch(t){case"x":this.add(this._meshY),this.add(this._meshZ);break;case"y":this.add(this._meshX),this.add(this._meshZ);break;case"z":this.add(this._meshX),this.add(this._meshY);break}else if(e==="rotate")switch(t){case"x":this.add(this._meshX);break;case"y":this.add(this._meshY);break;case"z":this.add(this._meshZ);break}}}class F extends s.Object3D{constructor(e){super();n(this,"_mode");n(this,"_gizmoNode");n(this,"_translateGizmo");n(this,"_rotateGizmo");n(this,"_scaleGizmo");n(this,"_gizmoPlane");n(this,"_object");this.name="DIVEGizmo",e.addEventListener("change",()=>{const t=e.getDistance()/2.5;this.scale.set(t,t,t)}),this._mode="translate",this._gizmoNode=new s.Object3D,this.add(this._gizmoNode),this._translateGizmo=new Y(e),this._rotateGizmo=new T(e),this._scaleGizmo=new j(e),this._gizmoPlane=new N,this._gizmoPlane.visible=!1,this._object=null}get mode(){return this._mode}set mode(e){this._mode=e,this.assemble()}set debug(e){this._translateGizmo.debug=e,this._rotateGizmo.debug=e,this._scaleGizmo.debug=e}get gizmoNode(){return this._gizmoNode}get gizmoPlane(){return this._gizmoPlane}get object(){return this._object}attach(e){return this._object=e,this.assemble(),this}detach(){return this._object=null,this.assemble(),this}onHover(e,t,o){o&&this._gizmoPlane.assemble(e,t)}onChange(e,t,o){this.object!==null&&(e&&(this.position.copy(e),this.object.position.copy(e)),t&&this.object.rotation.copy(t),o&&(this.object.scale.copy(o),this._scaleGizmo.update(o)))}assemble(){this._gizmoNode.clear(),this._gizmoPlane.clear(),this._translateGizmo.reset(),this._rotateGizmo.reset(),this._scaleGizmo.reset(),this.object!==null&&(this._mode==="translate"&&this._gizmoNode.add(this._translateGizmo),this._mode==="rotate"&&this._gizmoNode.add(this._rotateGizmo),this._mode==="scale"&&this._gizmoNode.add(this._scaleGizmo),this.add(this._gizmoPlane))}}class U{constructor(){n(this,"isMovable",!0)}}class K{constructor(){n(this,"isSelectable",!0)}}function X(r,i){return i.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(o=>{if(o==="constructor")return;const h=Object.getOwnPropertyDescriptor(e.prototype,o);Object.defineProperty(r.prototype,o,h)});const t=new e;Object.getOwnPropertyNames(t).forEach(o=>{const h=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r.prototype,o,h)})}),r}function f(r,i=new WeakMap){if(r===null||typeof r!="object")return r;if(i.has(r))return i.get(r);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const a=[];i.set(r,a);for(let l=0;l<r.length;l++)a[l]=f(r[l],i);return a}if(r instanceof Map){const a=new Map;i.set(r,a);for(const[l,d]of r)a.set(f(l,i),f(d,i));return a}if(r instanceof Set){const a=new Set;i.set(r,a);for(const l of r)a.add(f(l,i));return a}const e=r;if(typeof e.clone=="function"){const a=e.clone();return i.set(r,a),a}const t=Object.create(Object.getPrototypeOf(r));i.set(r,t);const o=Object.getOwnPropertyNames(r);for(const a of o){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}const h=Object.getOwnPropertySymbols(r);for(const a of h){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}return t}const I=(r,i)=>{if(Object.keys(r).length===0&&Object.keys(i).length===0)return{};if(typeof r!="object"||typeof i!="object")return i;let e={};return Object.keys(i).forEach(t=>{if(!Object.keys(r).includes(t)){e={...e,[t]:i[t]};return}if(Array.isArray(i[t])){if(!Array.isArray(r[t])){e={...e,[t]:i[t]};return}const o=r[t],h=i[t];if(o.length===0&&h.length===0){e={...e};return}if(o.length!==h.length){e={...e,[t]:i[t]};return}const a=[];if(h.forEach((l,d)=>{const g=I(o[d],h[d]);Object.keys(g).length&&a.push(h[d])}),Object.keys(a).length){e={...e,[t]:a};return}return}if(typeof i[t]=="object"){if(typeof r[t]!="object"){e={...e,[t]:i[t]};return}const o=I(r[t],i[t]);if(Object.keys(o).length){e={...e,[t]:o};return}}r[t]!==i[t]&&(e={...e,[t]:i[t]})}),e};function q(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function Z(r){return r.entityType==="primitive"}exports.BoundingBox=c.BoundingBox;exports.DIVE=c.DIVE;exports.DIVEAmbientLight=c.DIVEAmbientLight;exports.DIVEClock=c.DIVEClock;exports.DIVEDefaultSettings=c.DIVEDefaultSettings;exports.DIVEEngine=c.DIVEEngine;exports.DIVEEnvironment=c.DIVEEnvironment;exports.DIVEEnvironmentDefaultSettings=c.DIVEEnvironmentDefaultSettings;exports.DIVEFloor=c.DIVEFloor;exports.DIVEGrid=c.DIVEGrid;exports.DIVEGroup=c.DIVEGroup;exports.DIVEModel=c.DIVEModel;exports.DIVENode=c.DIVENode;exports.DIVEPointLight=c.DIVEPointLight;exports.DIVEPrimitive=c.DIVEPrimitive;exports.DIVERenderPipeline=c.DIVERenderPipeline;exports.DIVERenderer=c.DIVERenderer;exports.DIVERendererDefaultSettings=c.DIVERendererDefaultSettings;exports.DIVEResizeManager=c.DIVEResizeManager;exports.DIVERoot=c.DIVERoot;exports.DIVEScene=c.DIVEScene;exports.DIVESceneDefaultSettings=c.DIVESceneDefaultSettings;exports.DIVESceneLight=c.DIVESceneLight;exports.DIVEView=c.DIVEView;exports.FILE_TYPES=c.FILE_TYPES;exports.GRID_CENTER_LINE_COLOR=c.GRID_CENTER_LINE_COLOR;exports.GRID_SIDE_LINE_COLOR=c.GRID_SIDE_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=c.SUPPORTED_FILE_TYPES;exports.findSceneRecursive=c.findSceneRecursive;exports.COORDINATE_LAYER_MASK=u.COORDINATE_LAYER_MASK;exports.DEFAULT_LAYER_MASK=u.DEFAULT_LAYER_MASK;exports.DIVEPerspectiveCamera=u.DIVEPerspectiveCamera;exports.DIVEPerspectiveCameraDefaultSettings=u.DIVEPerspectiveCameraDefaultSettings;exports.HELPER_LAYER_MASK=u.HELPER_LAYER_MASK;exports.PRODUCT_LAYER_MASK=u.PRODUCT_LAYER_MASK;exports.UI_LAYER_MASK=u.UI_LAYER_MASK;exports.AxesColorBlue=_.AxesColorBlue;exports.AxesColorBlueLetter=_.AxesColorBlueLetter;exports.AxesColorGreen=_.AxesColorGreen;exports.AxesColorGreenLetter=_.AxesColorGreenLetter;exports.AxesColorRed=_.AxesColorRed;exports.AxesColorRedLetter=_.AxesColorRedLetter;exports.findInterface=V.findInterface;exports.implementsInterface=V.implementsInterface;exports.getFileTypeFromUri=y.getFileTypeFromUri;exports.isFileTypeSupported=y.isFileTypeSupported;exports.FileContentError=w.FileContentError;exports.NetworkError=w.NetworkError;exports.FileTypeError=A.FileTypeError;exports.ParseError=A.ParseError;exports.isModelSchema=P.isModelSchema;exports.isPovSchema=P.isPovSchema;exports.DIVEGizmo=F;exports.DIVEMath=S;exports.DIVEMovable=U;exports.DIVESelectable=K;exports.applyMixins=X;exports.deepClone=f;exports.getObjectDelta=I;exports.isGroupSchema=q;exports.isLightSchema=B;exports.isPrimitiveSchema=Z;
|
package/build/dive.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var S = Object.defineProperty;
|
|
2
2
|
var A = (r, s, t) => s in r ? S(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
|
|
3
3
|
var i = (r, s, t) => A(r, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
-
import { B as ot, b as ht, d as lt, e as ct, D as dt, f as pt, g as ut, h as ft, i as _t, j as gt, k as mt, c as Et, l as Dt, m as wt, n as yt, o as Mt, p as xt, q as It, r as Pt, s as Vt, t as bt, u as Ht, v as zt, w as vt, F as Ot, G as St, x as At, S as Gt, y as Rt } from "./chunks/FileTypes-
|
|
4
|
+
import { B as ot, b as ht, d as lt, e as ct, D as dt, f as pt, g as ut, h as ft, i as _t, j as gt, k as mt, c as Et, l as Dt, m as wt, n as yt, o as Mt, p as xt, q as It, r as Pt, s as Vt, t as bt, u as Ht, v as zt, w as vt, F as Ot, G as St, x as At, S as Gt, y as Rt } from "./chunks/FileTypes-B8g1qxjR.mjs";
|
|
5
5
|
import { U as d } from "./chunks/PerspectiveCamera-BFzE2TQU.mjs";
|
|
6
6
|
import { C as Yt, b as jt, D as Ct, a as Lt, H as Nt, P as Xt } from "./chunks/PerspectiveCamera-BFzE2TQU.mjs";
|
|
7
7
|
import { A as I, a as P, b as V } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
8
8
|
import { e as Zt, d as qt, c as Qt } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
9
9
|
import { Object3D as f, Color as b, Vector3 as c, TorusGeometry as H, MeshBasicMaterial as g, Mesh as p, MathUtils as v, Euler as G, CylinderGeometry as E, BoxGeometry as R, PlaneGeometry as w } from "three";
|
|
10
10
|
import { f as kt, i as Ut } from "./chunks/findInterface-DbJ5qzbc.mjs";
|
|
11
|
-
import { g as Kt, i as Jt } from "./chunks/isFileTypeSupported-
|
|
11
|
+
import { g as Kt, i as Jt } from "./chunks/isFileTypeSupported-DA7cjOZa.mjs";
|
|
12
12
|
import { F as te, N as ee } from "./chunks/network-error-BONfHWQq.mjs";
|
|
13
13
|
import { F as se, P as ie } from "./chunks/parse-error-DfOPyLWM.mjs";
|
|
14
14
|
import { i as ae, a as oe } from "./chunks/PovSchema-DWWvr_ED.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var u=(s,t,e)=>t in s?m(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var n=(s,t,e)=>u(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@tweenjs/tween.js"),c=require("three");class l{constructor(){n(this,"uuid",c.MathUtils.generateUUID());n(this,"Easing",o.Easing);n(this,"_animators",new Map)}dispose(){for(const t of this._animators.values())t.dispose();this._animators.clear()}tick(t){for(const e of this._animators.values())e.update(t)}async animate(t,e,i){const a=await this.fromTargets(t,e,i);return a.play(),a}async fromTargets(t,e,i){const{TargetAnimator:a}=await Promise.resolve().then(()=>require("../../chunks/TargetAnimator-DuqPk2eq.cjs")),r=new a(t,e,i);return this._animators.set(r.uuid,r),r}async fromClips(t,e){const{ClipAnimator:i}=await Promise.resolve().then(()=>require("../../chunks/ClipAnimator-CNKeT7rW.cjs")),a=new i(t,e);return this._animators.set(a.uuid,a),a}remove(t){const e=this._animators.get(t);if(!e){console.warn(`Animator with uuid ${t} not found`);return}e.dispose(),this._animators.delete(t)}}Object.defineProperty(exports,"Easing",{enumerable:!0,get:()=>o.Easing});exports.AnimationSystem=l;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './src/index.ts';
|
|
2
|
-
export
|
|
2
|
+
export { Easing } from '@tweenjs/tween.js';
|
|
@@ -1,126 +1,101 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
1
|
+
var e = Object.defineProperty;
|
|
2
|
+
var m = (i, t, a) => t in i ? e(i, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : i[t] = a;
|
|
3
|
+
var n = (i, t, a) => m(i, typeof t != "symbol" ? t + "" : t, a);
|
|
4
|
+
import { Easing as c } from "@tweenjs/tween.js";
|
|
5
|
+
import { Easing as w } from "@tweenjs/tween.js";
|
|
5
6
|
import { MathUtils as p } from "three";
|
|
6
|
-
class
|
|
7
|
-
|
|
8
|
-
this
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
hasEventListener(e, t) {
|
|
13
|
-
if (this._listeners === void 0) return !1;
|
|
14
|
-
const i = this._listeners;
|
|
15
|
-
return i[e] !== void 0 && i[e].indexOf(t) !== -1;
|
|
16
|
-
}
|
|
17
|
-
removeEventListener(e, t) {
|
|
18
|
-
if (this._listeners === void 0) return;
|
|
19
|
-
const n = this._listeners[e];
|
|
20
|
-
if (n !== void 0) {
|
|
21
|
-
const s = n.indexOf(t);
|
|
22
|
-
s !== -1 && n.splice(s, 1);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
dispatchEvent(e) {
|
|
26
|
-
if (this._listeners === void 0) return;
|
|
27
|
-
const i = this._listeners[e.type];
|
|
28
|
-
if (i !== void 0) {
|
|
29
|
-
e.target = this;
|
|
30
|
-
const n = i.slice(0);
|
|
31
|
-
for (let s = 0, l = n.length; s < l; s++)
|
|
32
|
-
n[s].call(this, e);
|
|
33
|
-
e.target = null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
class _ extends u {
|
|
38
|
-
constructor(t, i, n, s) {
|
|
39
|
-
super();
|
|
40
|
-
r(this, "_uuid", p.generateUUID());
|
|
41
|
-
r(this, "_playing", !1);
|
|
42
|
-
r(this, "_stopped", !1);
|
|
43
|
-
r(this, "_completed", !1);
|
|
44
|
-
this.object = t, this.to = i, this.duration = n, this.options = s;
|
|
45
|
-
}
|
|
46
|
-
get uuid() {
|
|
47
|
-
return this._uuid;
|
|
48
|
-
}
|
|
49
|
-
get playing() {
|
|
50
|
-
return this._playing;
|
|
51
|
-
}
|
|
52
|
-
get stopped() {
|
|
53
|
-
return this._stopped;
|
|
54
|
-
}
|
|
55
|
-
get completed() {
|
|
56
|
-
return this._completed;
|
|
7
|
+
class l {
|
|
8
|
+
constructor() {
|
|
9
|
+
n(this, "uuid", p.generateUUID());
|
|
10
|
+
n(this, "Easing", c);
|
|
11
|
+
n(this, "_animators", /* @__PURE__ */ new Map());
|
|
57
12
|
}
|
|
58
13
|
dispose() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return this._playing = !0, this._stopped = !1, this.dispatchEvent({ type: "play", target: this }), this;
|
|
14
|
+
for (const t of this._animators.values())
|
|
15
|
+
t.dispose();
|
|
16
|
+
this._animators.clear();
|
|
63
17
|
}
|
|
64
|
-
|
|
65
|
-
|
|
18
|
+
tick(t) {
|
|
19
|
+
for (const a of this._animators.values())
|
|
20
|
+
a.update(t);
|
|
66
21
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Use `fromTargets()` instead.
|
|
24
|
+
* @note This method also calls .play() on the animator automatically. This has been removed in fromTargets(). You have to call .play() independently after creating the animator.
|
|
25
|
+
*/
|
|
26
|
+
async animate(t, a, s) {
|
|
27
|
+
const o = await this.fromTargets(t, a, s);
|
|
28
|
+
return o.play(), o;
|
|
74
29
|
}
|
|
75
30
|
/**
|
|
76
|
-
* Creates a
|
|
77
|
-
*
|
|
78
|
-
* @
|
|
31
|
+
* Creates a TargetAnimator and returns it asynchronously.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Animate a single target (e.g. position).
|
|
35
|
+
* const animator = await animationSystem.fromTargets(
|
|
36
|
+
* { position: { x: 0, y: 0, z: 0 }, to: { x: 10, y: 10, z: 10 } },
|
|
37
|
+
* 1000,
|
|
38
|
+
* );
|
|
39
|
+
* // animate the target
|
|
40
|
+
* animator.play();
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Animate multiple targets (e.g. position and rotation) at once using an array.
|
|
44
|
+
* const animator = await animationSystem.fromTargets(
|
|
45
|
+
* [
|
|
46
|
+
* { position: { x: 0, y: 0, z: 0 }, to: { x: 10, y: 10, z: 10 } },
|
|
47
|
+
* { rotation: { x: 0, y: 0, z: 0 }, to: { x: 0, y: Math.PI / 2, z: 0 } },
|
|
48
|
+
* ],
|
|
49
|
+
* 1000,
|
|
50
|
+
* );
|
|
51
|
+
* // animate all targets in the array at once
|
|
52
|
+
* animator.play();
|
|
53
|
+
* @param targets - The targets to animate.
|
|
79
54
|
* @param duration - The duration of the animation in milliseconds.
|
|
80
55
|
* @param options - The options for the animation.
|
|
81
|
-
* @returns
|
|
56
|
+
* @returns Promise<TargetAnimator>.
|
|
57
|
+
*/
|
|
58
|
+
async fromTargets(t, a, s) {
|
|
59
|
+
const { TargetAnimator: o } = await import("../../chunks/TargetAnimator-DUqkkdVb.mjs"), r = new o(t, a, s);
|
|
60
|
+
return this._animators.set(r.uuid, r), r;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates a ClipAnimator and returns it asynchronously.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // Animate a single clip (e.g. a single animation) at once.
|
|
67
|
+
* const animator = await animationSystem.fromClips(
|
|
68
|
+
* model,
|
|
69
|
+
* model.animations,
|
|
70
|
+
* );
|
|
71
|
+
* // plays first clip by default
|
|
72
|
+
* animator.play();
|
|
73
|
+
* // plays plays "Idle" clip by name
|
|
74
|
+
* animator.play("Idle");
|
|
75
|
+
*
|
|
76
|
+
* @param root - The root object to animate.
|
|
77
|
+
* @param clips - The animation clips to animate.
|
|
78
|
+
* @returns Promise<ClipAnimator>.
|
|
82
79
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return this._callbackMap.set(s.uuid, {
|
|
87
|
-
onUpdate: ((l = s.options) == null ? void 0 : l.onUpdate) ?? (() => {
|
|
88
|
-
}),
|
|
89
|
-
onComplete: ((o = s.options) == null ? void 0 : o.onComplete) ?? (() => {
|
|
90
|
-
})
|
|
91
|
-
}), this._createTween(s), s;
|
|
80
|
+
async fromClips(t, a) {
|
|
81
|
+
const { ClipAnimator: s } = await import("../../chunks/ClipAnimator-BJZ4_C4B.mjs"), o = new s(t, a);
|
|
82
|
+
return this._animators.set(o.uuid, o), o;
|
|
92
83
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Removes an animator from the system.
|
|
86
|
+
*
|
|
87
|
+
* @param uuid - The UUID of the animator to remove.
|
|
88
|
+
*/
|
|
89
|
+
remove(t) {
|
|
90
|
+
const a = this._animators.get(t);
|
|
91
|
+
if (!a) {
|
|
92
|
+
console.warn(`Animator with uuid ${t} not found`);
|
|
96
93
|
return;
|
|
97
94
|
}
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
dispose() {
|
|
101
|
-
this._callbackMap.clear(), this._tweens.clear();
|
|
102
|
-
}
|
|
103
|
-
tick() {
|
|
104
|
-
this.TWEEN.update();
|
|
105
|
-
}
|
|
106
|
-
_createTween(e) {
|
|
107
|
-
var i;
|
|
108
|
-
const t = new this.TWEEN.Tween(e.object).to(e.to, e.duration).easing(((i = e.options) == null ? void 0 : i.easing) ?? this.TWEEN.Easing.Quadratic.Out).onUpdate((n, s) => {
|
|
109
|
-
var l;
|
|
110
|
-
(l = this._callbackMap.get(e.uuid)) == null || l.onUpdate(n, s);
|
|
111
|
-
}).onComplete((n) => {
|
|
112
|
-
var s;
|
|
113
|
-
(s = this._callbackMap.get(e.uuid)) == null || s.onComplete(n);
|
|
114
|
-
});
|
|
115
|
-
e.addEventListener("play", () => {
|
|
116
|
-
t.start();
|
|
117
|
-
}), e.addEventListener("stop", () => {
|
|
118
|
-
t.stop();
|
|
119
|
-
}), this._tweens.set(e.uuid, t);
|
|
95
|
+
a.dispose(), this._animators.delete(t);
|
|
120
96
|
}
|
|
121
97
|
}
|
|
122
98
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
c as TWEEN
|
|
99
|
+
l as AnimationSystem,
|
|
100
|
+
w as Easing
|
|
126
101
|
};
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { EventDispatcher
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { EventDispatcher } from 'three/src/core/EventDispatcher.js';
|
|
2
|
+
import { TAnimatorEventMap, TAnimatorLoopMode, TAnimatorState } from '../types/AnimatorTypes.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class for all animation types.
|
|
5
|
+
*
|
|
6
|
+
* Provides a unified interface for controlling animations,
|
|
7
|
+
* regardless of the underlying implementation (Tween or AnimationClip).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class Animator extends EventDispatcher<TAnimatorEventMap> {
|
|
12
12
|
private _uuid;
|
|
13
|
-
private _playing;
|
|
14
|
-
private _stopped;
|
|
15
|
-
private _completed;
|
|
16
|
-
constructor(object: T, to: T, duration: number, options?: TAnimatorParameters<T> | undefined);
|
|
17
13
|
get uuid(): string;
|
|
18
|
-
get
|
|
19
|
-
get
|
|
20
|
-
get
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
abstract get state(): TAnimatorState;
|
|
15
|
+
abstract get duration(): number;
|
|
16
|
+
abstract get loop(): TAnimatorLoopMode;
|
|
17
|
+
abstract set loop(value: TAnimatorLoopMode);
|
|
18
|
+
abstract get time(): number;
|
|
19
|
+
abstract set time(value: number);
|
|
20
|
+
abstract play(): this;
|
|
21
|
+
abstract pause(): this;
|
|
22
|
+
abstract resume(): this;
|
|
23
|
+
abstract stop(): this;
|
|
24
|
+
abstract update(deltaTime: number): void;
|
|
25
|
+
abstract dispose(): void;
|
|
24
26
|
}
|
|
25
|
-
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AnimationClip, Object3D } from 'three';
|
|
2
|
+
import { Animator } from './Animator.ts';
|
|
3
|
+
import { TAnimatorLoopMode, TAnimatorState } from '../types/AnimatorTypes.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Animator for mesh-embedded AnimationClip playback (e.g. character animations, keyframe animations).
|
|
6
|
+
*
|
|
7
|
+
* Wraps Three.js AnimationMixer and AnimationAction into the unified Animator interface.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
export declare class ClipAnimator extends Animator {
|
|
12
|
+
private _mixer;
|
|
13
|
+
private _actions;
|
|
14
|
+
private _currentAction;
|
|
15
|
+
private _state;
|
|
16
|
+
private _loop;
|
|
17
|
+
constructor(root: Object3D, clips: AnimationClip[]);
|
|
18
|
+
get state(): TAnimatorState;
|
|
19
|
+
get duration(): number;
|
|
20
|
+
get loop(): TAnimatorLoopMode;
|
|
21
|
+
set loop(value: TAnimatorLoopMode);
|
|
22
|
+
private _resolveLoopConstant;
|
|
23
|
+
get time(): number;
|
|
24
|
+
set time(value: number);
|
|
25
|
+
get clipNames(): string[];
|
|
26
|
+
get currentClipName(): string | null;
|
|
27
|
+
play(clipName?: string): this;
|
|
28
|
+
pause(): this;
|
|
29
|
+
resume(): this;
|
|
30
|
+
stop(): this;
|
|
31
|
+
update(deltaTime: number): void;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Animator } from './Animator.ts';
|
|
2
|
+
import { TAnimatorLoopMode, TAnimatorState } from '../types/AnimatorTypes.ts';
|
|
3
|
+
type EasingFunction = (amount: number) => number;
|
|
4
|
+
export type AnimationTarget = {
|
|
5
|
+
object: any;
|
|
6
|
+
to: any;
|
|
7
|
+
};
|
|
8
|
+
export type TargetAnimatorOptions = {
|
|
9
|
+
easing?: EasingFunction;
|
|
10
|
+
onUpdate?: () => void;
|
|
11
|
+
onComplete?: () => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Animator for programmatic target-based animations.
|
|
15
|
+
*
|
|
16
|
+
* Bundles multiple animation targets into a single logical animation unit
|
|
17
|
+
* using an isolated TWEEN.Group per instance.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
export declare class TargetAnimator extends Animator {
|
|
22
|
+
private _group;
|
|
23
|
+
private _tweens;
|
|
24
|
+
private _snapshots;
|
|
25
|
+
private _state;
|
|
26
|
+
private _duration;
|
|
27
|
+
private _loop;
|
|
28
|
+
private _options?;
|
|
29
|
+
private _completedCount;
|
|
30
|
+
constructor(targets: AnimationTarget | AnimationTarget[], duration: number, options?: TargetAnimatorOptions);
|
|
31
|
+
get state(): TAnimatorState;
|
|
32
|
+
get duration(): number;
|
|
33
|
+
get loop(): TAnimatorLoopMode;
|
|
34
|
+
set loop(value: TAnimatorLoopMode);
|
|
35
|
+
get time(): number;
|
|
36
|
+
set time(_value: number);
|
|
37
|
+
play(): this;
|
|
38
|
+
pause(): this;
|
|
39
|
+
resume(): this;
|
|
40
|
+
stop(): this;
|
|
41
|
+
update(): void;
|
|
42
|
+
private _restoreSnapshots;
|
|
43
|
+
dispose(): void;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export * from './system/AnimationSystem.ts';
|
|
2
|
-
export * from './
|
|
3
|
-
export
|
|
2
|
+
export * from './types/AnimatorTypes.ts';
|
|
3
|
+
export type { Animator } from './animator/Animator.ts';
|
|
4
|
+
export type { ClipAnimator } from './animator/ClipAnimator.ts';
|
|
5
|
+
export type { TargetAnimator, AnimationTarget, TargetAnimatorOptions, } from './animator/TargetAnimator.ts';
|