@shopware-ag/dive 3.0.10 → 3.1.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/build/chunks/{AssetCache-MDlWClMZ.mjs → AssetCache-C3YXhbaX.mjs} +1 -1
- package/build/chunks/{AssetCache-Bpo1xXAi.cjs → AssetCache-xpY_N7Yp.cjs} +1 -1
- package/build/chunks/{AssetExporter-DLL_vJae.mjs → AssetExporter-C5MScs9S.mjs} +4 -1
- package/build/chunks/{AssetLoader-D74krc4-.cjs → AssetLoader-CRxLq0AL.cjs} +1 -1
- package/build/chunks/{AssetLoader-jcAcbdux.mjs → AssetLoader-MfH5d_Rr.mjs} +6 -15
- package/build/chunks/{PovSchema-DWWvr_ED.mjs → CameraSchema-cgY5WBGW.mjs} +4 -4
- package/build/chunks/CameraSchema-twxH-72N.cjs +1 -0
- package/build/chunks/{FileTypes-DQSGehEU.cjs → FileTypes-Cgyf8ocm.cjs} +2 -2
- package/build/chunks/{FileTypes-DSSukt5S.mjs → FileTypes-DiYB3WBp.mjs} +208 -183
- package/build/chunks/SpriteText-2lCRglsw.cjs +1 -0
- package/build/chunks/SpriteText-C_CQPvUn.mjs +50 -0
- package/build/chunks/{isFileTypeSupported-KHXcJ7rI.mjs → isFileTypeSupported-9h8lrIuG.mjs} +1 -1
- package/build/chunks/{isFileTypeSupported-DWpn0l_-.cjs → isFileTypeSupported-BBU39V4u.cjs} +1 -1
- package/build/components/boundingbox/BoundingBox.d.ts +9 -5
- package/build/components/index.d.ts +1 -0
- package/build/components/root/Root.d.ts +2 -2
- package/build/components/spritetext/SpriteText.d.ts +27 -0
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +36 -37
- package/build/engine/Dive.d.ts +6 -0
- package/build/engine/environment/Environment.d.ts +8 -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.mjs +1 -1
- 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/orbitcontroller/src/OrbitController.d.ts +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +4 -4
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +49 -19
- package/build/plugins/quickview/src/QuickView.d.ts +12 -8
- package/build/plugins/quickview/src/state/QuickViewState.d.ts +4 -0
- package/build/plugins/quickview/src/uri/QuickViewUri.d.ts +3 -0
- package/build/plugins/quickview/types/index.d.ts +18 -0
- package/build/plugins/state/index.cjs +13 -13
- package/build/plugins/state/index.mjs +2343 -2168
- package/build/plugins/state/src/actions/index.d.ts +1 -0
- package/build/plugins/state/src/actions/object/addobject.d.ts +1 -1
- package/build/plugins/state/src/actions/object/updateobject.d.ts +1 -1
- package/build/plugins/state/src/actions/renderer/startrender.d.ts +1 -1
- package/build/plugins/state/src/actions/scene/getallscenedata.d.ts +5 -2
- package/build/plugins/state/src/actions/state/getstate.d.ts +8 -0
- package/build/plugins/state/src/actions/state/index.d.ts +2 -0
- package/build/plugins/state/src/actions/state/setstate.d.ts +8 -0
- package/build/plugins/state/types/StateData.d.ts +18 -0
- package/build/plugins/state/types/StateSceneData.d.ts +5 -19
- package/build/plugins/state/types/index.d.ts +1 -0
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +4 -13
- package/build/types/schema/BaseEntitySchema.d.ts +17 -0
- package/build/types/schema/CameraSchema.d.ts +18 -0
- package/build/types/schema/EntitySchema.d.ts +13 -3
- package/build/types/schema/EntityTypeSchema.d.ts +9 -1
- package/build/types/schema/GeometrySchema.d.ts +9 -0
- package/build/types/schema/GeometryTypeSchema.d.ts +6 -0
- package/build/types/schema/GroupSchema.d.ts +7 -0
- package/build/types/schema/LightSchema.d.ts +16 -0
- package/build/types/schema/MaterialSchema.d.ts +10 -0
- package/build/types/schema/ModelSchema.d.ts +16 -0
- package/build/types/schema/PrimitiveSchema.d.ts +5 -0
- package/build/types/schema/index.d.ts +1 -1
- package/package.json +8 -9
- package/build/chunks/PovSchema-Co9FznEz.cjs +0 -1
- package/build/types/schema/PovSchema.d.ts +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var x=Object.defineProperty;var _=(i,e,t)=>e in i?x(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var s=(i,e,t)=>_(i,typeof e!="symbol"?e+"":e,t);const r=require("three/webgpu"),h=90,o=`normal ${h}px Arial`;class c extends r.Sprite{constructor(t,a=1,n=16777215){super(new r.SpriteMaterial);s(this,"isDIVESpriteText",!0);s(this,"_text");s(this,"_textHeight");s(this,"_color");s(this,"_canvas");s(this,"_texture");this.name="DIVESpriteText",this._text=t,this._textHeight=a,this._color=new r.Color(n),this._canvas=document.createElement("canvas"),this._texture=new r.CanvasTexture(this._canvas),this._texture.colorSpace=r.SRGBColorSpace,this.material.map=this._texture,this._draw()}setText(t){this._text=t,this._draw()}setTextHeight(t){this._textHeight=t,this._draw()}setColor(t){this._color=new r.Color(t),this._draw()}dispose(){this._texture.dispose(),this.material.dispose()}_draw(){const t=this._canvas.getContext("2d");if(t===null)return;t.font=o;const a=Math.max(1,Math.ceil(t.measureText(this._text).width));this._canvas.width=a,this._canvas.height=h,t.font=o,t.fillStyle=`#${this._color.getHexString()}`,t.textBaseline="bottom",t.fillText(this._text,0,h),this._texture.needsUpdate=!0,this.scale.set(this._textHeight*a/h,this._textHeight,1)}}exports.DIVESpriteText=c;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var n = (i, e, t) => e in i ? _(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var s = (i, e, t) => n(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Sprite as c, SpriteMaterial as l, Color as h, CanvasTexture as d, SRGBColorSpace as p } from "three/webgpu";
|
|
5
|
+
const r = 90, o = `normal ${r}px Arial`;
|
|
6
|
+
class w extends c {
|
|
7
|
+
constructor(t, a = 1, x = 16777215) {
|
|
8
|
+
super(new l());
|
|
9
|
+
s(this, "isDIVESpriteText", !0);
|
|
10
|
+
s(this, "_text");
|
|
11
|
+
s(this, "_textHeight");
|
|
12
|
+
s(this, "_color");
|
|
13
|
+
s(this, "_canvas");
|
|
14
|
+
s(this, "_texture");
|
|
15
|
+
this.name = "DIVESpriteText", this._text = t, this._textHeight = a, this._color = new h(x), this._canvas = document.createElement("canvas"), this._texture = new d(this._canvas), this._texture.colorSpace = p, this.material.map = this._texture, this._draw();
|
|
16
|
+
}
|
|
17
|
+
setText(t) {
|
|
18
|
+
this._text = t, this._draw();
|
|
19
|
+
}
|
|
20
|
+
setTextHeight(t) {
|
|
21
|
+
this._textHeight = t, this._draw();
|
|
22
|
+
}
|
|
23
|
+
setColor(t) {
|
|
24
|
+
this._color = new h(t), this._draw();
|
|
25
|
+
}
|
|
26
|
+
dispose() {
|
|
27
|
+
this._texture.dispose(), this.material.dispose();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Rasterizes the text to the canvas and scales the sprite to the resulting
|
|
31
|
+
* aspect ratio, so the label's height matches its text height in world units.
|
|
32
|
+
*/
|
|
33
|
+
_draw() {
|
|
34
|
+
const t = this._canvas.getContext("2d");
|
|
35
|
+
if (t === null) return;
|
|
36
|
+
t.font = o;
|
|
37
|
+
const a = Math.max(
|
|
38
|
+
1,
|
|
39
|
+
Math.ceil(t.measureText(this._text).width)
|
|
40
|
+
);
|
|
41
|
+
this._canvas.width = a, this._canvas.height = r, t.font = o, t.fillStyle = `#${this._color.getHexString()}`, t.textBaseline = "bottom", t.fillText(this._text, 0, r), this._texture.needsUpdate = !0, this.scale.set(
|
|
42
|
+
this._textHeight * a / r,
|
|
43
|
+
this._textHeight,
|
|
44
|
+
1
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
w as D
|
|
50
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./FileTypes-
|
|
1
|
+
"use strict";const n=require("./FileTypes-Cgyf8ocm.cjs");function o(e){var t;const i=(e.split("/").pop()||"").split(/[?#]/)[0];return!i.includes(".")||i.endsWith(".")?"":((t=i.split(".").pop())==null?void 0:t.toLowerCase())||""}function r(e){return e.toLowerCase()in n.FILE_TYPES}exports.getFileTypeFromUri=o;exports.isFileTypeSupported=r;
|
|
@@ -77,12 +77,13 @@ export declare class BoundingBox extends DIVENode {
|
|
|
77
77
|
*/
|
|
78
78
|
get size(): Vector3;
|
|
79
79
|
/**
|
|
80
|
-
* Creates a new BoundingBox instance for the specified 3D object.
|
|
80
|
+
* Creates a new BoundingBox instance for the specified 3D object or objects.
|
|
81
81
|
*
|
|
82
|
-
* The constructor computes both a bounding box and bounding sphere for the given
|
|
83
|
-
* It handles complex objects with multiple meshes and nested transformations.
|
|
82
|
+
* The constructor computes both a bounding box and bounding sphere for the given objects.
|
|
83
|
+
* It handles complex objects with multiple meshes and nested transformations. When several
|
|
84
|
+
* objects are passed, the resulting volumes encompass all of them.
|
|
84
85
|
*
|
|
85
|
-
* @param object - The 3D object to compute bounding volumes for
|
|
86
|
+
* @param object - The 3D object, or objects, to compute bounding volumes for
|
|
86
87
|
* @param axisAligned - Whether to create an axis-aligned bounding box (true) or oriented bounding box (false). Defaults to false.
|
|
87
88
|
* @param wireframeColor - The color for the wireframe helpers. Can be a hex number or ColorRepresentation. Defaults to green (0x00ff00).
|
|
88
89
|
*
|
|
@@ -94,11 +95,14 @@ export declare class BoundingBox extends DIVENode {
|
|
|
94
95
|
* // Create an axis-aligned bounding box (aligned with world coordinates)
|
|
95
96
|
* const aabb = new BoundingBox(mesh, true, 0xff0000);
|
|
96
97
|
*
|
|
98
|
+
* // Encompass several objects at once
|
|
99
|
+
* const combined = new BoundingBox([meshA, meshB, meshC]);
|
|
100
|
+
*
|
|
97
101
|
* // Use default green color
|
|
98
102
|
* const defaultBox = new BoundingBox(mesh);
|
|
99
103
|
* ```
|
|
100
104
|
*/
|
|
101
|
-
constructor(object: Object3D, axisAligned?: boolean, wireframeColor?: ColorRepresentation | number);
|
|
105
|
+
constructor(object: Object3D | Object3D[], axisAligned?: boolean, wireframeColor?: ColorRepresentation | number);
|
|
102
106
|
/**
|
|
103
107
|
* Sets the visibility of the bounding box wireframe helper.
|
|
104
108
|
*
|
|
@@ -17,8 +17,8 @@ export declare class DIVERoot extends Object3D {
|
|
|
17
17
|
id: string;
|
|
18
18
|
entityType: E;
|
|
19
19
|
}): DIVESceneObject<E> | undefined;
|
|
20
|
-
addSceneObject(object: EntitySchema): DIVESceneObject | undefined
|
|
21
|
-
updateSceneObject(object: PartialSchema): void
|
|
20
|
+
addSceneObject(object: EntitySchema): Promise<DIVESceneObject | undefined>;
|
|
21
|
+
updateSceneObject(object: PartialSchema): Promise<void>;
|
|
22
22
|
deleteSceneObject(object: MinimalSchema<EntitySchema>): void;
|
|
23
23
|
private _updateLight;
|
|
24
24
|
private _updateModel;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ColorRepresentation, Sprite } from 'three/webgpu';
|
|
2
|
+
/**
|
|
3
|
+
* A camera facing text label.
|
|
4
|
+
*
|
|
5
|
+
* The text is rasterized to a canvas and applied to a sprite, so the label always
|
|
6
|
+
* faces the camera while keeping a constant height in world units.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export declare class DIVESpriteText extends Sprite {
|
|
11
|
+
readonly isDIVESpriteText: true;
|
|
12
|
+
private _text;
|
|
13
|
+
private _textHeight;
|
|
14
|
+
private _color;
|
|
15
|
+
private _canvas;
|
|
16
|
+
private _texture;
|
|
17
|
+
constructor(text: string, textHeight?: number, color?: ColorRepresentation);
|
|
18
|
+
setText(text: string): void;
|
|
19
|
+
setTextHeight(textHeight: number): void;
|
|
20
|
+
setColor(color: ColorRepresentation): void;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Rasterizes the text to the canvas and scales the sprite to the resulting
|
|
24
|
+
* aspect ratio, so the label's height matches its text height in world units.
|
|
25
|
+
*/
|
|
26
|
+
private _draw;
|
|
27
|
+
}
|
package/build/dive.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var R=Object.defineProperty;var O=(r,i,e)=>i in r?R(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>O(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./chunks/FileTypes-DQSGehEU.cjs"),u=require("./chunks/PerspectiveCamera-DwQUmkDv.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three/webgpu"),y=require("./chunks/findInterface-C6mrvf_t.cjs"),V=require("./chunks/isFileTypeSupported-DWpn0l_-.cjs"),P=require("./chunks/network-error-CdDXil5g.cjs"),w=require("./chunks/parse-error-Dy_EE4rL.cjs"),S=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 v(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function H(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function A(r,i=0){if(r<0)return-A(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function G(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 L(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 T(r){return s.MathUtils.degToRad(r)}const x={ceilExp:v,floorExp:H,roundExp:A,toFixedExp:z,truncateExp:L,signedAngleTo:G,radToDeg:C,degToRad:T};class Y 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=x.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 j 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 F 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 U 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 N 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 j(e),this._rotateGizmo=new Y(e),this._scaleGizmo=new F(e),this._gizmoPlane=new U,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 K{constructor(){n(this,"isMovable",!0)}}class X{constructor(){n(this,"isSelectable",!0)}}function q(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 B(r){return c.SUPPORTED_MIME_TYPES.includes(r.toLowerCase())}function b(r){return r.toLowerCase()in c.FILE_TYPES}function Z(r){return b(V.getFileTypeFromUri(r))}function k(r){return r.entityType==="group"}function Q(r){return r.entityType==="light"}function W(r){return r.entityType==="primitive"}exports.BoundingBox=c.BoundingBox;exports.DIVE=c.DIVE;exports.DIVEAbortablePromise=c.DIVEAbortablePromise;exports.DIVEAmbientLight=c.DIVEAmbientLight;exports.DIVECanvasLifecycleManager=c.DIVECanvasLifecycleManager;exports.DIVEClock=c.DIVEClock;exports.DIVEDefaultSettings=c.DIVEDefaultSettings;exports.DIVEDeferredPromise=c.DIVEDeferredPromise;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.DIVERenderer=c.DIVERenderer;exports.DIVERendererDefaultSettings=c.DIVERendererDefaultSettings;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_MAJOR_LINE_COLOR=c.GRID_MAJOR_LINE_COLOR;exports.GRID_MINOR_LINE_COLOR=c.GRID_MINOR_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=c.SUPPORTED_FILE_TYPES;exports.SUPPORTED_MIME_TYPES=c.SUPPORTED_MIME_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=y.findInterface;exports.implementsInterface=y.implementsInterface;exports.getFileTypeFromUri=V.getFileTypeFromUri;exports.isFileTypeSupported=V.isFileTypeSupported;exports.FileContentError=P.FileContentError;exports.NetworkError=P.NetworkError;exports.FileTypeError=w.FileTypeError;exports.ParseError=w.ParseError;exports.isModelSchema=S.isModelSchema;exports.isPovSchema=S.isPovSchema;exports.DIVEGizmo=N;exports.DIVEMath=x;exports.DIVEMovable=K;exports.DIVESelectable=X;exports.applyMixins=q;exports.deepClone=f;exports.getObjectDelta=I;exports.isFileExtensionSupported=b;exports.isGroupSchema=k;exports.isLightSchema=Q;exports.isMimeTypeSupported=B;exports.isPrimitiveSchema=W;exports.isURIFileExtensionSupported=Z;
|
|
1
|
+
"use strict";var R=Object.defineProperty;var O=(r,i,e)=>i in r?R(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>O(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./chunks/FileTypes-Cgyf8ocm.cjs"),u=require("./chunks/PerspectiveCamera-DwQUmkDv.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three/webgpu"),v=require("./chunks/SpriteText-2lCRglsw.cjs"),y=require("./chunks/findInterface-C6mrvf_t.cjs"),V=require("./chunks/isFileTypeSupported-BBU39V4u.cjs"),S=require("./chunks/network-error-CdDXil5g.cjs"),P=require("./chunks/parse-error-Dy_EE4rL.cjs"),w=require("./chunks/CameraSchema-twxH-72N.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 H(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function C(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 G(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 L(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function T(r){return(s.MathUtils.radToDeg(r)+360)%360}function Y(r){return s.MathUtils.degToRad(r)}const A={ceilExp:H,floorExp:C,roundExp:x,toFixedExp:z,truncateExp:L,signedAngleTo:G,radToDeg:T,degToRad:Y};class j 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=A.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 F 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 U 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 K 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 F(e),this._rotateGizmo=new j(e),this._scaleGizmo=new U(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 X{constructor(){n(this,"isMovable",!0)}}class q{constructor(){n(this,"isSelectable",!0)}}function B(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 Z(r){return c.SUPPORTED_MIME_TYPES.includes(r.toLowerCase())}function b(r){return r.toLowerCase()in c.FILE_TYPES}function k(r){return b(V.getFileTypeFromUri(r))}function Q(r){return r.entityType==="group"}function W(r){return r.entityType==="light"}function J(r){return r.entityType==="primitive"}exports.BoundingBox=c.BoundingBox;exports.DIVE=c.DIVE;exports.DIVEAbortablePromise=c.DIVEAbortablePromise;exports.DIVEAmbientLight=c.DIVEAmbientLight;exports.DIVECanvasLifecycleManager=c.DIVECanvasLifecycleManager;exports.DIVEClock=c.DIVEClock;exports.DIVEDefaultSettings=c.DIVEDefaultSettings;exports.DIVEDeferredPromise=c.DIVEDeferredPromise;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.DIVERenderer=c.DIVERenderer;exports.DIVERendererDefaultSettings=c.DIVERendererDefaultSettings;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_MAJOR_LINE_COLOR=c.GRID_MAJOR_LINE_COLOR;exports.GRID_MINOR_LINE_COLOR=c.GRID_MINOR_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=c.SUPPORTED_FILE_TYPES;exports.SUPPORTED_MIME_TYPES=c.SUPPORTED_MIME_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.DIVESpriteText=v.DIVESpriteText;exports.findInterface=y.findInterface;exports.implementsInterface=y.implementsInterface;exports.getFileTypeFromUri=V.getFileTypeFromUri;exports.isFileTypeSupported=V.isFileTypeSupported;exports.FileContentError=S.FileContentError;exports.NetworkError=S.NetworkError;exports.FileTypeError=P.FileTypeError;exports.ParseError=P.ParseError;exports.isCameraSchema=w.isCameraSchema;exports.isModelSchema=w.isModelSchema;exports.DIVEGizmo=K;exports.DIVEMath=A;exports.DIVEMovable=X;exports.DIVESelectable=q;exports.applyMixins=B;exports.deepClone=f;exports.getObjectDelta=I;exports.isFileExtensionSupported=b;exports.isGroupSchema=Q;exports.isLightSchema=W;exports.isMimeTypeSupported=Z;exports.isPrimitiveSchema=J;exports.isURIFileExtensionSupported=k;
|
package/build/dive.mjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var A = (r, s, t) => s in r ?
|
|
1
|
+
var O = Object.defineProperty;
|
|
2
|
+
var A = (r, s, t) => s in r ? O(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 { d as G, F as R } from "./chunks/FileTypes-
|
|
5
|
-
import { B as _t,
|
|
4
|
+
import { d as G, F as R } from "./chunks/FileTypes-DiYB3WBp.mjs";
|
|
5
|
+
import { B as _t, D as gt, e as mt, f as Et, g as Dt, h as wt, c as yt, i as Mt, j as xt, k as It, l as Pt, m as Vt, n as bt, b as Ht, o as zt, p as vt, q as St, r as Ot, s as At, t as Gt, u as Rt, v as Tt, w as Ct, x as Lt, G as Yt, y as jt, S as Nt, z as Xt } from "./chunks/FileTypes-DiYB3WBp.mjs";
|
|
6
6
|
import { U as d } from "./chunks/PerspectiveCamera-B5TvUzTa.mjs";
|
|
7
7
|
import { C as Zt, b as qt, D as Qt, a as Ut, H as Wt, P as kt } from "./chunks/PerspectiveCamera-B5TvUzTa.mjs";
|
|
8
8
|
import { A as I, a as P, b as V } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
9
9
|
import { e as Kt, d as Jt, c as $t } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
10
|
-
import { Object3D as f, Color as b, Vector3 as c, TorusGeometry as H, MeshBasicMaterial as g, Mesh as p, MathUtils as v, Euler as T, CylinderGeometry as E, BoxGeometry as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { F as
|
|
16
|
-
import {
|
|
10
|
+
import { Object3D as f, Color as b, Vector3 as c, TorusGeometry as H, MeshBasicMaterial as g, Mesh as p, MathUtils as v, Euler as T, CylinderGeometry as E, BoxGeometry as C, PlaneGeometry as w } from "three/webgpu";
|
|
11
|
+
import { D as ee } from "./chunks/SpriteText-C_CQPvUn.mjs";
|
|
12
|
+
import { f as se, i as ie } from "./chunks/findInterface-DbJ5qzbc.mjs";
|
|
13
|
+
import { g as L } from "./chunks/isFileTypeSupported-9h8lrIuG.mjs";
|
|
14
|
+
import { i as ae } from "./chunks/isFileTypeSupported-9h8lrIuG.mjs";
|
|
15
|
+
import { F as he, N as le } from "./chunks/network-error-BONfHWQq.mjs";
|
|
16
|
+
import { F as de, P as pe } from "./chunks/parse-error-DfOPyLWM.mjs";
|
|
17
|
+
import { i as fe, a as _e } from "./chunks/CameraSchema-cgY5WBGW.mjs";
|
|
17
18
|
class y extends f {
|
|
18
19
|
constructor(t, e, n, o, a) {
|
|
19
20
|
super();
|
|
@@ -86,7 +87,7 @@ function u(r, s) {
|
|
|
86
87
|
const t = (r + "e").split("e");
|
|
87
88
|
return +(t[0] + "e" + (+t[1] + (s || 0)));
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
+
function Y(r, s = 0) {
|
|
90
91
|
const t = u(r, +s);
|
|
91
92
|
return u(Math.ceil(t), -s);
|
|
92
93
|
}
|
|
@@ -94,8 +95,8 @@ function j(r, s = 0) {
|
|
|
94
95
|
const t = u(r, +s);
|
|
95
96
|
return u(Math.floor(t), -s);
|
|
96
97
|
}
|
|
97
|
-
function
|
|
98
|
-
if (r < 0) return -
|
|
98
|
+
function S(r, s = 0) {
|
|
99
|
+
if (r < 0) return -S(-r, s);
|
|
99
100
|
const t = u(r, +s);
|
|
100
101
|
return u(Math.round(t), -s);
|
|
101
102
|
}
|
|
@@ -120,9 +121,9 @@ function q(r) {
|
|
|
120
121
|
return v.degToRad(r);
|
|
121
122
|
}
|
|
122
123
|
const Q = {
|
|
123
|
-
ceilExp:
|
|
124
|
+
ceilExp: Y,
|
|
124
125
|
floorExp: j,
|
|
125
|
-
roundExp:
|
|
126
|
+
roundExp: S,
|
|
126
127
|
toFixedExp: X,
|
|
127
128
|
truncateExp: F,
|
|
128
129
|
signedAngleTo: N,
|
|
@@ -350,7 +351,7 @@ class x extends f {
|
|
|
350
351
|
});
|
|
351
352
|
const l = new p(h, this._lineMaterial);
|
|
352
353
|
l.layers.mask = d, l.renderOrder = 1 / 0, l.rotateX(Math.PI / 2), l.translateY(e / 2 - a / 4), this.add(l), this._box = new p(
|
|
353
|
-
new
|
|
354
|
+
new C(a, a, a),
|
|
354
355
|
this._lineMaterial
|
|
355
356
|
), this._box.layers.mask = d, this._box.renderOrder = 1 / 0, this._box.rotateX(Math.PI / 2), this._box.translateY(e - a / 2), this._box.rotateZ(n.x * Math.PI / 2), this._box.rotateX(n.z * Math.PI / 2), this.add(this._box);
|
|
356
357
|
const _ = new E(
|
|
@@ -629,10 +630,7 @@ function m(r, s = /* @__PURE__ */ new WeakMap()) {
|
|
|
629
630
|
if (r instanceof Map) {
|
|
630
631
|
const a = /* @__PURE__ */ new Map();
|
|
631
632
|
s.set(r, a);
|
|
632
|
-
for (const [
|
|
633
|
-
h,
|
|
634
|
-
l
|
|
635
|
-
] of r)
|
|
633
|
+
for (const [h, l] of r)
|
|
636
634
|
a.set(m(h, s), m(l, s));
|
|
637
635
|
return a;
|
|
638
636
|
}
|
|
@@ -740,7 +738,7 @@ function K(r) {
|
|
|
740
738
|
return r.toLowerCase() in R;
|
|
741
739
|
}
|
|
742
740
|
function lt(r) {
|
|
743
|
-
return K(
|
|
741
|
+
return K(L(r));
|
|
744
742
|
}
|
|
745
743
|
function ct(r) {
|
|
746
744
|
return r.entityType === "group";
|
|
@@ -781,41 +779,42 @@ export {
|
|
|
781
779
|
Qt as DIVEPerspectiveCamera,
|
|
782
780
|
Ut as DIVEPerspectiveCameraDefaultSettings,
|
|
783
781
|
vt as DIVEPointLight,
|
|
784
|
-
|
|
785
|
-
|
|
782
|
+
St as DIVEPrimitive,
|
|
783
|
+
Ot as DIVERenderer,
|
|
786
784
|
At as DIVERendererDefaultSettings,
|
|
787
785
|
Gt as DIVERoot,
|
|
788
786
|
Rt as DIVEScene,
|
|
789
787
|
Tt as DIVESceneDefaultSettings,
|
|
790
|
-
|
|
788
|
+
Ct as DIVESceneLight,
|
|
791
789
|
at as DIVESelectable,
|
|
792
|
-
|
|
790
|
+
ee as DIVESpriteText,
|
|
791
|
+
Lt as DIVEView,
|
|
793
792
|
R as FILE_TYPES,
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
793
|
+
he as FileContentError,
|
|
794
|
+
de as FileTypeError,
|
|
795
|
+
Yt as GRID_MAJOR_LINE_COLOR,
|
|
797
796
|
jt as GRID_MINOR_LINE_COLOR,
|
|
798
797
|
Wt as HELPER_LAYER_MASK,
|
|
799
|
-
|
|
798
|
+
le as NetworkError,
|
|
800
799
|
kt as PRODUCT_LAYER_MASK,
|
|
801
|
-
|
|
800
|
+
pe as ParseError,
|
|
802
801
|
Nt as SUPPORTED_FILE_TYPES,
|
|
803
802
|
G as SUPPORTED_MIME_TYPES,
|
|
804
803
|
d as UI_LAYER_MASK,
|
|
805
804
|
ot as applyMixins,
|
|
806
805
|
m as deepClone,
|
|
807
|
-
|
|
806
|
+
se as findInterface,
|
|
808
807
|
Xt as findSceneRecursive,
|
|
809
|
-
|
|
808
|
+
L as getFileTypeFromUri,
|
|
810
809
|
z as getObjectDelta,
|
|
811
|
-
|
|
810
|
+
ie as implementsInterface,
|
|
811
|
+
fe as isCameraSchema,
|
|
812
812
|
K as isFileExtensionSupported,
|
|
813
|
-
|
|
813
|
+
ae as isFileTypeSupported,
|
|
814
814
|
ct as isGroupSchema,
|
|
815
815
|
dt as isLightSchema,
|
|
816
816
|
ht as isMimeTypeSupported,
|
|
817
|
-
|
|
818
|
-
ue as isPovSchema,
|
|
817
|
+
_e as isModelSchema,
|
|
819
818
|
pt as isPrimitiveSchema,
|
|
820
819
|
lt as isURIFileExtensionSupported
|
|
821
820
|
};
|
package/build/engine/Dive.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ declare global {
|
|
|
15
15
|
* Get the first instance of DIVE
|
|
16
16
|
*/
|
|
17
17
|
get instance(): DIVE | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Maximum amount of DIVE instances that can be created. This is checked on initialization of a new instance.
|
|
20
|
+
*
|
|
21
|
+
* You can change this value to allow more instances, but be aware that this can lead to performance issues and crashes.
|
|
22
|
+
*/
|
|
23
|
+
instanceLimit: number;
|
|
18
24
|
};
|
|
19
25
|
}
|
|
20
26
|
}
|
|
@@ -53,6 +53,7 @@ export declare const DIVEEnvironmentDefaultSettings: DIVEEnvironmentSettings;
|
|
|
53
53
|
*/
|
|
54
54
|
export declare class DIVEEnvironment {
|
|
55
55
|
private originalBackground;
|
|
56
|
+
private installedBackground;
|
|
56
57
|
private _webgpurenderer;
|
|
57
58
|
private scene;
|
|
58
59
|
private pmrem;
|
|
@@ -71,6 +72,13 @@ export declare class DIVEEnvironment {
|
|
|
71
72
|
* Disposes the environment.
|
|
72
73
|
*/
|
|
73
74
|
dispose(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Whether `scene.background` is still the one this environment installed.
|
|
77
|
+
*
|
|
78
|
+
* A foreign value means something else has changed the background in the
|
|
79
|
+
* meantime, which makes it the value to restore instead.
|
|
80
|
+
*/
|
|
81
|
+
private ownsSceneBackground;
|
|
74
82
|
private clearEnvironment;
|
|
75
83
|
/**
|
|
76
84
|
* Updates the environment.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-
|
|
1
|
+
"use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-CRxLq0AL.cjs");require("three/examples/jsm/loaders/DRACOLoader.js");const w=require("../../chunks/AssetExporter-Cdxb04b3.cjs");var m=(o=>(o.AR_DESKTOP_PLATFORM_ERROR="ar-desktop-platform-error",o.AR_QUICK_LOOK_NOT_SAFARI_ERROR="ar-quicklook-not-safari-error",o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR="ar-quicklook-version-mismatch-error",o.AR_QUICK_LOOK_UNKNOWN_ERROR="ar-quicklook-unknown-error",o))(m||{});class a extends Error{constructor(r,t){super(r);l(this,"type");this.name=this.constructor.name,this.type=t,Object.setPrototypeOf(this,new.target.prototype)}}class R extends a{constructor(){super("AR features are not supported on desktop platforms.","ar-desktop-platform-error")}}class p extends a{constructor(){super("ARQuickLook on iOS is only available in Safari.","ar-quicklook-not-safari-error")}}class d extends a{constructor(e,r){super(`ARQuickLook requires iOS version ${r} or later. Current version: ${e}.`,"ar-quicklook-version-mismatch-error"),this.currentVersion=e,this.requiredVersion=r}}class u extends a{constructor(){super("An unknown ARQuickLook compatibility error occurred.","ar-quicklook-unknown-error")}}const k=12;class S{constructor(){l(this,"converter",new A.AssetConverter(new O.AssetLoader,new w.AssetExporter))}async launch(e,r){if(c.SystemInfo.getBrowser()!==c.EBrowser.SAFARI)return Promise.reject(new p);const t=c.SystemInfo.getIOSVersion();if(t&&t.major<k)return Promise.reject(new d(t.full,k));if(!t)return Promise.reject(new u);if(!c.SystemInfo.getSupportsARQuickLook())return Promise.reject(new u);const n=await this.convertToUSDZ(e,r);return this.launchARQuickLook(n,r)}async convertToUSDZ(e,r){const t=await this.converter.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),n=new Blob([t],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(n)}launchARQuickLook(e,r){return new Promise(t=>{(r==null?void 0:r.arScale)==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const n=document.createElement("a");n.innerHTML="<picture></picture>",n.rel="ar",n.href=e,n.download="scene.usdz",t(),n.click()})}}class _{launch(e,r){const t=self.location.toString(),n=document.createElement("a"),s=this._createParams(t,e,r),i=this._createIntent(t,e,s);n.setAttribute("href",i),n.click()}_createParams(e,r,t){const n=new URL(r,e),s=new URLSearchParams(n.search);return s.set("mode","ar_preferred"),this._applyScaleOption(s,t),this._applyPlacementOption(s,t),this._applySoundOption(s,e),this._applyLinkOption(s,e),s}_applyScaleOption(e,r){(r==null?void 0:r.arScale)==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,r){(r==null?void 0:r.arPlacement)==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,r){if(e.has("sound")){const t=new URL(e.get("sound"),r);e.set("sound",t.toString())}}_applyLinkOption(e,r){if(e.has("link")){const t=new URL(e.get("link"),r);e.set("link",t.toString())}}_createIntent(e,r,t){const n=new URL(e),s=new URL(r,e),i="#model-viewer-no-ar-fallback";return n.hash=i,`intent://arvr.google.com/scene-viewer/1.2?${t.toString()+"&file="+s.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(n.toString())};end;`}}class L{async launch(e,r){const t=c.SystemInfo.getSystem();return t===c.ESystem.IOS?new S().launch(e,r):t===c.ESystem.ANDROID?new _().launch(e,r):Promise.reject(new R)}}exports.ARDesktopPlatformError=R;exports.ARError=a;exports.ARQuickLook=S;exports.ARQuickLookNotSafariError=p;exports.ARQuickLookUnknownError=u;exports.ARQuickLookVersionMismatchError=d;exports.ARSystem=L;exports.EARErrorType=m;exports.SceneViewer=_;
|
|
@@ -3,9 +3,9 @@ var R = (o, e, r) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var l = (o, e, r) => R(o, typeof e != "symbol" ? e + "" : e, r);
|
|
4
4
|
import { SystemInfo as c, EBrowser as d, ESystem as u } from "../systeminfo/index.mjs";
|
|
5
5
|
import { AssetConverter as h } from "../assetconverter/index.mjs";
|
|
6
|
-
import { A as _ } from "../../chunks/AssetLoader-
|
|
6
|
+
import { A as _ } from "../../chunks/AssetLoader-MfH5d_Rr.mjs";
|
|
7
7
|
import "three/examples/jsm/loaders/DRACOLoader.js";
|
|
8
|
-
import { A as f } from "../../chunks/AssetExporter-
|
|
8
|
+
import { A as f } from "../../chunks/AssetExporter-C5MScs9S.mjs";
|
|
9
9
|
var S = /* @__PURE__ */ ((o) => (o.AR_DESKTOP_PLATFORM_ERROR = "ar-desktop-platform-error", o.AR_QUICK_LOOK_NOT_SAFARI_ERROR = "ar-quicklook-not-safari-error", o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR = "ar-quicklook-version-mismatch-error", o.AR_QUICK_LOOK_UNKNOWN_ERROR = "ar-quicklook-unknown-error", o))(S || {});
|
|
10
10
|
class a extends Error {
|
|
11
11
|
constructor(r, t) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-xpY_N7Yp.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-CRxLq0AL.cjs");exports.AssetLoader=e.AssetLoader;exports.DRACOWorker=e.DRACOWorker;exports.DracoLoader=e.DracoLoader;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as o } from "../../chunks/AssetLoader-
|
|
2
|
-
import { D as s, a as t } from "../../chunks/AssetLoader-
|
|
1
|
+
import { A as o } from "../../chunks/AssetLoader-MfH5d_Rr.mjs";
|
|
2
|
+
import { D as s, a as t } from "../../chunks/AssetLoader-MfH5d_Rr.mjs";
|
|
3
3
|
export {
|
|
4
4
|
o as AssetLoader,
|
|
5
5
|
s as DRACOWorker,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-Cgyf8ocm.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
|
|
@@ -141,7 +141,7 @@ export declare class OrbitController extends EventDispatcher<EventMap> implement
|
|
|
141
141
|
position: Vector3Like;
|
|
142
142
|
target: Vector3Like;
|
|
143
143
|
};
|
|
144
|
-
focusObject(
|
|
144
|
+
focusObject(objects: Object3D | Object3D[], padding?: number): void;
|
|
145
145
|
zoomIn(by?: number): void;
|
|
146
146
|
zoomOut(by?: number): void;
|
|
147
147
|
getState(): OrbitControllerState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var c=(s,r,e)=>r in s?p(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e;var o=(s,r,e)=>c(s,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("three/webgpu");require("../../chunks/FileTypes-
|
|
1
|
+
"use strict";var p=Object.defineProperty;var c=(s,r,e)=>r in s?p(s,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[r]=e;var o=(s,r,e)=>c(s,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("three/webgpu");require("../../chunks/FileTypes-Cgyf8ocm.cjs");const h=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const n=require("../../chunks/AxisHelperColors-BrGqktN5.cjs"),_=require("../../chunks/SpriteText-2lCRglsw.cjs");class l extends t.Object3D{constructor(){super();o(this,"_axesHelper");this._axesHelper=new t.AxesHelper(.5),this._axesHelper.layers.mask=h.COORDINATE_LAYER_MASK,this._axesHelper.material.depthTest=!1,this._axesHelper.position.set(0,0,-1),this._axesHelper.setColors(new t.Color(n.AxesColorRed),new t.Color(n.AxesColorGreen),new t.Color(n.AxesColorBlue));const e=new _.DIVESpriteText("X",.2,n.AxesColorRedLetter),i=new _.DIVESpriteText("Y",.2,n.AxesColorGreenLetter),a=new _.DIVESpriteText("Z",.2,n.AxesColorBlueLetter);e.layers.mask=h.COORDINATE_LAYER_MASK,i.layers.mask=h.COORDINATE_LAYER_MASK,a.layers.mask=h.COORDINATE_LAYER_MASK,e.position.set(.7,0,0),i.position.set(0,.7,0),a.position.set(0,0,.7),this._axesHelper.add(e),this._axesHelper.add(i),this._axesHelper.add(a),this.add(this._axesHelper)}setFromCameraMatrix(e){this._axesHelper.rotation.setFromRotationMatrix(new t.Matrix4().extractRotation(e).invert())}}class d{constructor(r,e,i){o(this,"uuid",t.MathUtils.generateUUID());o(this,"_axes");o(this,"_orthographicCamera");o(this,"_restoreViewport",new t.Vector4);this._renderer=r,this._scene=e,this._camera=i,this._orthographicCamera=new t.OrthographicCamera(-1,1,1,-1,.1,100),this._orthographicCamera.name="OrientationDisplayCamera",this._orthographicCamera.layers.mask=h.COORDINATE_LAYER_MASK,this._scene.add(this._orthographicCamera),this._axes=new l,this._axes.name="OrientationDisplayAxes",this._scene.add(this._axes)}tick(){var a;if(!this._renderer.webgpurenderer.initialized)return;const r=this._scene.background??null,e=this._renderer.webgpurenderer.autoClear;this._scene.background=null,this._renderer.webgpurenderer.getViewport(this._restoreViewport);const i=((a=this._renderer.webgpurenderer.domElement)==null?void 0:a.clientHeight)??this._restoreViewport.w;this._renderer.webgpurenderer.setViewport(0,Math.max(0,i-150),150,150),this._renderer.webgpurenderer.autoClear=!1,this._axes.setFromCameraMatrix(this._camera.matrix),this._renderer.webgpurenderer.render(this._scene,this._orthographicCamera),this._renderer.webgpurenderer.setViewport(this._restoreViewport),this._renderer.webgpurenderer.autoClear=e,this._scene.background=r}dispose(){this._scene.remove(this._axes),this._scene.remove(this._orthographicCamera)}}exports.OrientationDisplay=d;exports.OrientationDisplayAxes=l;
|
|
@@ -2,12 +2,12 @@ var p = Object.defineProperty;
|
|
|
2
2
|
var _ = (t, r, e) => r in t ? p(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
|
|
3
3
|
var i = (t, r, e) => _(t, typeof r != "symbol" ? r + "" : r, e);
|
|
4
4
|
import { Object3D as l, AxesHelper as d, Color as n, Matrix4 as c, OrthographicCamera as m, MathUtils as x, Vector4 as w } from "three/webgpu";
|
|
5
|
-
import "../../chunks/FileTypes-
|
|
5
|
+
import "../../chunks/FileTypes-DiYB3WBp.mjs";
|
|
6
6
|
import { C as o } from "../../chunks/PerspectiveCamera-B5TvUzTa.mjs";
|
|
7
7
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
8
8
|
import "three/tsl";
|
|
9
9
|
import { A as u, a as g, b as C, c as b, d as A, e as H } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
10
|
-
import h from "
|
|
10
|
+
import { D as h } from "../../chunks/SpriteText-C_CQPvUn.mjs";
|
|
11
11
|
class k extends l {
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
@@ -26,7 +26,7 @@ class k extends l {
|
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
class
|
|
29
|
+
class E {
|
|
30
30
|
constructor(r, e, s) {
|
|
31
31
|
i(this, "uuid", x.generateUUID());
|
|
32
32
|
i(this, "_axes");
|
|
@@ -62,6 +62,6 @@ class L {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
export {
|
|
65
|
-
|
|
65
|
+
E as OrientationDisplay,
|
|
66
66
|
k as OrientationDisplayAxes
|
|
67
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../chunks/FileTypes-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../chunks/FileTypes-Cgyf8ocm.cjs");require("three/webgpu");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const u=async(r,i)=>{try{const e=new a.DIVE({...i,autoStart:!1});e.mainView.camera.position.set(0,1,2);const t=await new a.DIVEModel().setFromURL(r);e.scene.root.add(t),t.placeOnFloor();const o=new a.OrbitController(e.mainView.camera,e.mainView.canvas);e.clock.addTicker(o);const c=Object.assign(e,{orbitController:o,model:t}),n=e.disposeAsync.bind(e);return c.disposeAsync=async()=>{o.dispose(),await n()},((i==null?void 0:i.autoStart)??!0)&&(await e.startAsync(),o.focusObject(t)),c}catch(e){return console.error("Failed to initialize QuickView:",e),Promise.reject(e)}},w=async(r,i)=>{try{const e=new a.DIVE({...i,autoStart:!1});e.mainView.camera.position.set(0,1,2);const t=new a.OrbitController(e.mainView.camera,e.mainView.canvas);e.clock.addTicker(t);const o=new(await Promise.resolve().then(()=>require("../state/index.cjs"))).State(e,t),c=Object.assign(e,{orbitController:t,state:o}),n=e.disposeAsync.bind(e);c.disposeAsync=async()=>{t.dispose(),o.destroyInstance(),await n()};const s=(await o.performAction("SET_STATE",r)).filter(l=>"isDIVEModel"in l||"isDIVEPrimitive"in l);return s.length>0&&t.focusObject(s),((i==null?void 0:i.autoStart)??!0)&&await e.startAsync(),c}catch(e){return console.error("Failed to initialize QuickView:",e),Promise.reject(e)}},d={...a.DIVEDefaultSettings};function V(r,i){return typeof r=="string"?u(r,i):w(r,i)}exports.QuickView=V;exports.QuickViewDefaultSettings=d;
|