@shopware-ag/dive 3.0.11 → 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-DOB996Vk.mjs → AssetCache-C3YXhbaX.mjs} +1 -1
- package/build/chunks/{AssetCache-MtISiPD2.cjs → AssetCache-xpY_N7Yp.cjs} +1 -1
- package/build/chunks/{AssetExporter-DLL_vJae.mjs → AssetExporter-C5MScs9S.mjs} +4 -1
- package/build/chunks/{AssetLoader-B1n3KGOu.cjs → AssetLoader-CRxLq0AL.cjs} +1 -1
- package/build/chunks/{AssetLoader-BY5D3Cvc.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-DMTSUCcK.cjs → FileTypes-Cgyf8ocm.cjs} +2 -2
- package/build/chunks/{FileTypes-DYtXCJQV.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-C-hfGk-7.mjs → isFileTypeSupported-9h8lrIuG.mjs} +1 -1
- package/build/chunks/{isFileTypeSupported-xoGjHFuz.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Action } from '../action.ts';
|
|
2
2
|
import { ActionDependencies } from '../../../types/index.ts';
|
|
3
3
|
import { EntitySchema } from '../../../../../index.ts';
|
|
4
|
-
export declare const AddObjectAction: new (payload: EntitySchema, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<EntitySchema, Pick<ActionDependencies, "registered" | "engine">,
|
|
4
|
+
export declare const AddObjectAction: new (payload: EntitySchema, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<EntitySchema, Pick<ActionDependencies, "registered" | "engine">, Promise<import('../../../../../index.ts').DIVEModel | import('../../../../../index.ts').DIVEGroup | import('../../../../../index.ts').DIVEPrimitive | import('../../../../../index.ts').DIVELight | undefined>>;
|
|
5
5
|
declare global {
|
|
6
6
|
interface ActionTypes {
|
|
7
7
|
ADD_OBJECT: typeof AddObjectAction;
|
|
@@ -5,7 +5,7 @@ export declare const UpdateObjectAction: new (payload: Partial<EntitySchema> & {
|
|
|
5
5
|
id: string;
|
|
6
6
|
}, dependencies: Pick<ActionDependencies, "registered" | "engine">) => Action<Partial<EntitySchema> & {
|
|
7
7
|
id: string;
|
|
8
|
-
}, Pick<ActionDependencies, "registered" | "engine">, void
|
|
8
|
+
}, Pick<ActionDependencies, "registered" | "engine">, Promise<void>>;
|
|
9
9
|
declare global {
|
|
10
10
|
interface ActionTypes {
|
|
11
11
|
UPDATE_OBJECT: typeof UpdateObjectAction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Action } from '../action.ts';
|
|
2
2
|
import { ActionDependencies } from '../../../types/index.ts';
|
|
3
|
-
export declare const StartRenderAction: new (payload: void, dependencies: Pick<ActionDependencies, "engine">) => Action<void, Pick<ActionDependencies, "engine">, void
|
|
3
|
+
export declare const StartRenderAction: new (payload: void, dependencies: Pick<ActionDependencies, "engine">) => Action<void, Pick<ActionDependencies, "engine">, Promise<void>>;
|
|
4
4
|
declare global {
|
|
5
5
|
interface ActionTypes {
|
|
6
6
|
START_RENDER: typeof StartRenderAction;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Action } from '../action.ts';
|
|
2
2
|
import { ActionDependencies } from '../../../types/index.ts';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { StateData } from '../../../types/StateData.ts';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use [`GetStateAction`](../state/getstate.ts) instead. This action will be removed in next major release.
|
|
6
|
+
*/
|
|
7
|
+
export declare const GetAllSceneDataAction: new (payload: object, dependencies: Pick<ActionDependencies, "registered" | "engine" | "controller">) => Action<object, Pick<ActionDependencies, "registered" | "engine" | "controller">, StateData>;
|
|
5
8
|
declare global {
|
|
6
9
|
interface ActionTypes {
|
|
7
10
|
GET_ALL_SCENE_DATA: typeof GetAllSceneDataAction;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Action } from '../action.ts';
|
|
2
|
+
import { ActionDependencies, StateData } from '../../../types/index.ts';
|
|
3
|
+
export declare const GetStateAction: new (payload: void, dependencies: Pick<ActionDependencies, "registered" | "engine" | "controller">) => Action<void, Pick<ActionDependencies, "registered" | "engine" | "controller">, StateData>;
|
|
4
|
+
declare global {
|
|
5
|
+
interface ActionTypes {
|
|
6
|
+
GET_STATE: typeof GetStateAction;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Action } from '../action.ts';
|
|
2
|
+
import { ActionDependencies, StateData } from '../../../types/index.ts';
|
|
3
|
+
export declare const SetStateAction: new (payload: StateData, dependencies: Pick<ActionDependencies, "registered" | "engine" | "controller">) => Action<StateData, Pick<ActionDependencies, "registered" | "engine" | "controller">, Promise<(import('../../../../../index.ts').DIVEModel | import('../../../../../index.ts').DIVEGroup | import('../../../../../index.ts').DIVEPrimitive | import('../../../../../index.ts').DIVELight)[]>>;
|
|
4
|
+
declare global {
|
|
5
|
+
interface ActionTypes {
|
|
6
|
+
SET_STATE: typeof SetStateAction;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Vector3Like } from 'three/webgpu';
|
|
2
|
+
import { GroupSchema, LightSchema, ModelSchema, CameraSchema, PrimitiveSchema } from '../../../index.ts';
|
|
3
|
+
export type StateData = {
|
|
4
|
+
name: string;
|
|
5
|
+
backgroundColor: string;
|
|
6
|
+
floorEnabled: boolean;
|
|
7
|
+
floorColor: string;
|
|
8
|
+
spotmarks: object[];
|
|
9
|
+
lights: LightSchema[];
|
|
10
|
+
objects: ModelSchema[];
|
|
11
|
+
cameras: CameraSchema[];
|
|
12
|
+
primitives: PrimitiveSchema[];
|
|
13
|
+
groups: GroupSchema[];
|
|
14
|
+
userCamera: {
|
|
15
|
+
position: Vector3Like;
|
|
16
|
+
target: Vector3Like;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
backgroundColor: string;
|
|
7
|
-
floorEnabled: boolean;
|
|
8
|
-
floorColor: string;
|
|
9
|
-
userCamera: {
|
|
10
|
-
position: Vector3Like;
|
|
11
|
-
target: Vector3Like;
|
|
12
|
-
};
|
|
13
|
-
spotmarks: object[];
|
|
14
|
-
lights: LightSchema[];
|
|
15
|
-
objects: ModelSchema[];
|
|
16
|
-
cameras: PovSchema[];
|
|
17
|
-
primitives: PrimitiveSchema[];
|
|
18
|
-
groups: GroupSchema[];
|
|
19
|
-
};
|
|
1
|
+
import { StateData } from './StateData.ts';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated use [`StateData`](./StateData.ts) type instead. This type will be removed in release 4.0.
|
|
4
|
+
*/
|
|
5
|
+
export type StateSceneData = StateData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var S=(n,t,e)=>t in n?y(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>S(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("three/webgpu");require("../../chunks/FileTypes-DMTSUCcK.cjs");const h=require("../../chunks/PerspectiveCamera-DwQUmkDv.cjs");require("three/examples/jsm/loaders/HDRLoader.js");require("three/tsl");const _=require("../../chunks/findInterface-C6mrvf_t.cjs"),T=require("three/examples/jsm/controls/TransformControls.js"),d=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class m{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){var e,s,i;this._selected!==t&&(this._selected&&((s=(e=this._selected).onDeselect)==null||s.call(e)),this._selected=t,(i=t.onSelect)==null||i.call(t),this.notifyListeners())}deselect(){var t,e;this._selected&&((e=(t=this._selected).onDeselect)==null||e.call(t),this._selected=null,this.notifyListeners())}onChange(t){this._listeners.add(t)}offChange(t){this._listeners.delete(t)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const t of this._listeners)t(this._selected)}}class b{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var t,e;this._hovered&&((e=(t=this._hovered).onPointerLeave)==null||e.call(t),this._hovered=null)}onPointerMove(t){var i,o,a,l,p,f,v;const e=t.modelIntersects[0],s=_.findInterface(e==null?void 0:e.object,"isHoverable");if(e&&s){if(!this._hovered){(i=s.onPointerEnter)==null||i.call(s,e),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(a=(o=this._hovered).onPointerLeave)==null||a.call(o),(l=s.onPointerEnter)==null||l.call(s,e),this._hovered=s;return}(p=s.onPointerOver)==null||p.call(s,e);return}this._hovered&&((v=(f=this._hovered).onPointerLeave)==null||v.call(f),this._hovered=null)}}const P=n=>n.name==="select";class g{constructor(t){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=t}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(t){const e=t.modelIntersects[0],s=_.findInterface(e==null?void 0:e.object,"isSelectable");if(!e||!s){this._selectionState.deselect();return}const i=this._selectionState.selected;i&&i.uuid===s.uuid||this._selectionState.select(s)}select(t){this._selectionState.select(t)}deselect(){this._selectionState.deselect()}}const w=n=>n.name==="transform";class u extends c.EventDispatcher{constructor(e,s,i){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_gizmoHelper");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=e,this._controller=s,this._selectionState=i,this._gizmo=this.initGizmo(),this._gizmoHelper=this._gizmo.getHelper(),this._scene.add(this._gizmoHelper),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const e=this._selectionState.selected;e&&this.attachGizmo(e)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(e){if(this._gizmo.dragging||e.uiIntersects.length>0&&e.uiIntersects.some(i=>this.isGizmoChild(i.object)))return!0}setGizmoMode(e){this._gizmo.mode=e}setGizmoVisible(e){this._gizmoVisible=e;const s=this._scene.children.includes(this._gizmoHelper);e&&!s?(this._scene.add(this._gizmoHelper),this._gizmo.getRaycaster().layers.enableAll()):!e&&s&&(this._scene.remove(this._gizmoHelper),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(e){this._scaleLinked=e}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmoHelper),this._gizmo.dispose()}onSelectionChange(e){e&&_.implementsInterface(e,"isMovable")?this.attachGizmo(e):this._gizmo.detach()}attachGizmo(e){_.implementsInterface(e,"isMovable")&&(this._gizmo.attach(e),this.setGizmoVisible(e.visible&&this._gizmoVisible))}isGizmoChild(e){let s=e;for(;s;){if(s===this._gizmoHelper)return!0;s=s.parent}return!1}initGizmo(){const e=new T.TransformControls(this._controller.object,this._controller.domElement);return e.mode="translate",e.getHelper().traverse(i=>{if(!("isMesh"in i))return;const o=i.material;i.name==="X"&&o.color.set(d.AxesColorRed),i.name==="Y"&&o.color.set(d.AxesColorGreen),i.name==="Z"&&o.color.set(d.AxesColorBlue),i.name==="XY"&&o.color.set(d.AxesColorBlue),i.name==="YZ"&&o.color.set(d.AxesColorRed),i.name==="XZ"&&o.color.set(d.AxesColorGreen)}),e.addEventListener("mouseDown",()=>{var i,o;this._controller.enabled=!1,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveStart)==null||o.call(i))}),e.addEventListener("objectChange",()=>{var i,o;if(_.implementsInterface(e.object,"isMovable")){if((o=(i=e.object).onMove)==null||o.call(i),this._scaleLinked&&e.object){const a=e.object.scale,l=(a.x+a.y+a.z)/3;e.object.scale.set(l,l,l)}switch(this.dispatchEvent({type:"object-change",object:e.object}),e.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:e.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:e.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:e.object});break}}}),e.addEventListener("mouseUp",()=>{var i,o;this._controller.enabled=!0,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveEnd)==null||o.call(i))}),e}}const C=.001;class D{constructor(t){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new c.Vector3);r(this,"_dragCurrent",new c.Vector3);r(this,"_dragEnd",new c.Vector3);r(this,"_dragDelta",new c.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new c.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(t){var e;t.pointerPrimaryDown&&(this._draggable=_.findInterface((e=t.intersects[0])==null?void 0:e.object,"isDraggable")||null)}onPointerMove(t){if(t.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this._dragging||t.lastPointerDown.distanceTo(t.pointer)>C&&this.startDrag(t),this._dragging))return this.updateDrag(t),!0}onPointerUp(t){this._dragging&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this.endDrag()),this._draggable=null}setDragRaycastTargets(t){this._dragRaycastTargets=t}startDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragStart.copy(e.point),this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.set(0,0,0),(i=(s=this._draggable)==null?void 0:s.onDragStart)==null||i.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(i=(s=this._draggable)==null?void 0:s.onDrag)==null||i.call(s,this.createDragEvent()))}endDrag(){var e,s;const t=this.createDragEvent();(s=(e=this._draggable)==null?void 0:e.onDragEnd)==null||s.call(e,t),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(t){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:t.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const E=.001;class M{constructor(t,e){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_productLayerMask");r(this,"_uiLayerMask");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=t,this._controller=e,this._canvas=e.domElement,this._selectionState=new m,this._raycaster=new c.Raycaster,this._pointer=new c.Vector2,this._lastPointerDown=new c.Vector2,this._productLayerMask=new c.Layers,this._productLayerMask.set(Math.log2(h.PRODUCT_LAYER_MASK)),this._uiLayerMask=new c.Layers,this._uiLayerMask.set(Math.log2(h.UI_LAYER_MASK)),this._tools=new Map([["hover",new b],["select",new g(this._selectionState)],["transform",new u(t,e,this._selectionState)],["drag",new D(e)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(t){var s;const e=this._tools.get(t);e&&(this._activeTools.has(t)||(this._activeTools.set(t,e),this.updateSortedTools(),(s=e.onActivate)==null||s.call(e)))}disableTool(t){var s;const e=this._activeTools.get(t);e&&((s=e.onDeactivate)==null||s.call(e),this._activeTools.delete(t),this.updateSortedTools())}isToolEnabled(t){return this._activeTools.has(t)}getTool(t){return this._tools.get(t)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var t;for(const e of this._activeTools.values())(t=e.onDeactivate)==null||t.call(e);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(t){var s;this.updatePointer(t);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerMove)==null?void 0:s.call(i,e))break}onPointerDown(t){var s;this.updatePointerState(t,!0),this.updatePointer(t),this._lastPointerDown.copy(this._pointer);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerDown)==null?void 0:s.call(i,e))break}onPointerUp(t){var i,o;this.updatePointer(t);const e=this.createPointerContext(t),s=!this.pointerWasDragged();for(const a of this._sortedActiveTools)if((i=a.onPointerUp)==null?void 0:i.call(a,e))break;if(s){for(const a of this._sortedActiveTools)if((o=a.onClick)==null?void 0:o.call(a,e))break}this.updatePointerState(t,!1)}onWheel(t){var s;const e=this.createWheelContext(t);for(const i of this._sortedActiveTools)if((s=i.onWheel)==null?void 0:s.call(i,e))break}createPointerContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK)}}updatePointer(t){this._pointer.x=t.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(t.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object)}updatePointerState(t,e){switch(t.button){case 0:this._pointerPrimaryDown=e;break;case 1:this._pointerMiddleDown=e;break;case 2:this._pointerSecondaryDown=e;break}}raycast(){this._raycaster.layers.mask=h.PRODUCT_LAYER_MASK|h.UI_LAYER_MASK;const t=this._scene.children.filter(e=>e.visible&&"isMesh"in e&&e.isMesh);return this._raycaster.intersectObjects(t,!0)}filterIntersectsByLayer(t,e){return t.filter(s=>(s.object.layers.mask&e)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((t,e)=>t.priority-e.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>E}}exports.DIVESelectTool=g;exports.DIVETransformTool=u;exports.DragTool=D;exports.HoverTool=b;exports.SelectTool=g;exports.SelectionState=m;exports.Toolbox=M;exports.TransformTool=u;exports.isSelectTool=P;exports.isTransformTool=w;
|
|
1
|
+
"use strict";var y=Object.defineProperty;var S=(n,t,e)=>t in n?y(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var r=(n,t,e)=>S(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=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 _=require("../../chunks/findInterface-C6mrvf_t.cjs"),T=require("three/examples/jsm/controls/TransformControls.js"),d=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class m{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(t){var e,s,i;this._selected!==t&&(this._selected&&((s=(e=this._selected).onDeselect)==null||s.call(e)),this._selected=t,(i=t.onSelect)==null||i.call(t),this.notifyListeners())}deselect(){var t,e;this._selected&&((e=(t=this._selected).onDeselect)==null||e.call(t),this._selected=null,this.notifyListeners())}onChange(t){this._listeners.add(t)}offChange(t){this._listeners.delete(t)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const t of this._listeners)t(this._selected)}}class b{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var t,e;this._hovered&&((e=(t=this._hovered).onPointerLeave)==null||e.call(t),this._hovered=null)}onPointerMove(t){var i,o,a,l,p,f,v;const e=t.modelIntersects[0],s=_.findInterface(e==null?void 0:e.object,"isHoverable");if(e&&s){if(!this._hovered){(i=s.onPointerEnter)==null||i.call(s,e),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(a=(o=this._hovered).onPointerLeave)==null||a.call(o),(l=s.onPointerEnter)==null||l.call(s,e),this._hovered=s;return}(p=s.onPointerOver)==null||p.call(s,e);return}this._hovered&&((v=(f=this._hovered).onPointerLeave)==null||v.call(f),this._hovered=null)}}const P=n=>n.name==="select";class g{constructor(t){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=t}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(t){const e=t.modelIntersects[0],s=_.findInterface(e==null?void 0:e.object,"isSelectable");if(!e||!s){this._selectionState.deselect();return}const i=this._selectionState.selected;i&&i.uuid===s.uuid||this._selectionState.select(s)}select(t){this._selectionState.select(t)}deselect(){this._selectionState.deselect()}}const w=n=>n.name==="transform";class u extends c.EventDispatcher{constructor(e,s,i){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_gizmoHelper");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=e,this._controller=s,this._selectionState=i,this._gizmo=this.initGizmo(),this._gizmoHelper=this._gizmo.getHelper(),this._scene.add(this._gizmoHelper),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const e=this._selectionState.selected;e&&this.attachGizmo(e)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(e){if(this._gizmo.dragging||e.uiIntersects.length>0&&e.uiIntersects.some(i=>this.isGizmoChild(i.object)))return!0}setGizmoMode(e){this._gizmo.mode=e}setGizmoVisible(e){this._gizmoVisible=e;const s=this._scene.children.includes(this._gizmoHelper);e&&!s?(this._scene.add(this._gizmoHelper),this._gizmo.getRaycaster().layers.enableAll()):!e&&s&&(this._scene.remove(this._gizmoHelper),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(e){this._scaleLinked=e}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmoHelper),this._gizmo.dispose()}onSelectionChange(e){e&&_.implementsInterface(e,"isMovable")?this.attachGizmo(e):this._gizmo.detach()}attachGizmo(e){_.implementsInterface(e,"isMovable")&&(this._gizmo.attach(e),this.setGizmoVisible(e.visible&&this._gizmoVisible))}isGizmoChild(e){let s=e;for(;s;){if(s===this._gizmoHelper)return!0;s=s.parent}return!1}initGizmo(){const e=new T.TransformControls(this._controller.object,this._controller.domElement);return e.mode="translate",e.getHelper().traverse(i=>{if(!("isMesh"in i))return;const o=i.material;i.name==="X"&&o.color.set(d.AxesColorRed),i.name==="Y"&&o.color.set(d.AxesColorGreen),i.name==="Z"&&o.color.set(d.AxesColorBlue),i.name==="XY"&&o.color.set(d.AxesColorBlue),i.name==="YZ"&&o.color.set(d.AxesColorRed),i.name==="XZ"&&o.color.set(d.AxesColorGreen)}),e.addEventListener("mouseDown",()=>{var i,o;this._controller.enabled=!1,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveStart)==null||o.call(i))}),e.addEventListener("objectChange",()=>{var i,o;if(_.implementsInterface(e.object,"isMovable")){if((o=(i=e.object).onMove)==null||o.call(i),this._scaleLinked&&e.object){const a=e.object.scale,l=(a.x+a.y+a.z)/3;e.object.scale.set(l,l,l)}switch(this.dispatchEvent({type:"object-change",object:e.object}),e.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:e.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:e.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:e.object});break}}}),e.addEventListener("mouseUp",()=>{var i,o;this._controller.enabled=!0,_.implementsInterface(e.object,"isMovable")&&((o=(i=e.object).onMoveEnd)==null||o.call(i))}),e}}const C=.001;class D{constructor(t){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new c.Vector3);r(this,"_dragCurrent",new c.Vector3);r(this,"_dragEnd",new c.Vector3);r(this,"_dragDelta",new c.Vector3);r(this,"_dragRaycastTargets",null);this._controller=t,this._raycaster=new c.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(t){var e;t.pointerPrimaryDown&&(this._draggable=_.findInterface((e=t.intersects[0])==null?void 0:e.object,"isDraggable")||null)}onPointerMove(t){if(t.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this._dragging||t.lastPointerDown.distanceTo(t.pointer)>C&&this.startDrag(t),this._dragging))return this.updateDrag(t),!0}onPointerUp(t){this._dragging&&(this._raycaster.setFromCamera(t.pointer,this._controller.object),this.endDrag()),this._draggable=null}setDragRaycastTargets(t){this._dragRaycastTargets=t}startDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragStart.copy(e.point),this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.set(0,0,0),(i=(s=this._draggable)==null?void 0:s.onDragStart)==null||i.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(t){var s,i;const e=this.getDragIntersect(t);e&&(this._dragCurrent.copy(e.point),this._dragEnd.copy(e.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(i=(s=this._draggable)==null?void 0:s.onDrag)==null||i.call(s,this.createDragEvent()))}endDrag(){var e,s;const t=this.createDragEvent();(s=(e=this._draggable)==null?void 0:e.onDragEnd)==null||s.call(e,t),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(t){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:t.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const E=.001;class M{constructor(t,e){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_productLayerMask");r(this,"_uiLayerMask");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=t,this._controller=e,this._canvas=e.domElement,this._selectionState=new m,this._raycaster=new c.Raycaster,this._pointer=new c.Vector2,this._lastPointerDown=new c.Vector2,this._productLayerMask=new c.Layers,this._productLayerMask.set(Math.log2(h.PRODUCT_LAYER_MASK)),this._uiLayerMask=new c.Layers,this._uiLayerMask.set(Math.log2(h.UI_LAYER_MASK)),this._tools=new Map([["hover",new b],["select",new g(this._selectionState)],["transform",new u(t,e,this._selectionState)],["drag",new D(e)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(t){var s;const e=this._tools.get(t);e&&(this._activeTools.has(t)||(this._activeTools.set(t,e),this.updateSortedTools(),(s=e.onActivate)==null||s.call(e)))}disableTool(t){var s;const e=this._activeTools.get(t);e&&((s=e.onDeactivate)==null||s.call(e),this._activeTools.delete(t),this.updateSortedTools())}isToolEnabled(t){return this._activeTools.has(t)}getTool(t){return this._tools.get(t)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var t;for(const e of this._activeTools.values())(t=e.onDeactivate)==null||t.call(e);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(t){var s;this.updatePointer(t);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerMove)==null?void 0:s.call(i,e))break}onPointerDown(t){var s;this.updatePointerState(t,!0),this.updatePointer(t),this._lastPointerDown.copy(this._pointer);const e=this.createPointerContext(t);for(const i of this._sortedActiveTools)if((s=i.onPointerDown)==null?void 0:s.call(i,e))break}onPointerUp(t){var i,o;this.updatePointer(t);const e=this.createPointerContext(t),s=!this.pointerWasDragged();for(const a of this._sortedActiveTools)if((i=a.onPointerUp)==null?void 0:i.call(a,e))break;if(s){for(const a of this._sortedActiveTools)if((o=a.onClick)==null?void 0:o.call(a,e))break}this.updatePointerState(t,!1)}onWheel(t){var s;const e=this.createWheelContext(t);for(const i of this._sortedActiveTools)if((s=i.onWheel)==null?void 0:s.call(i,e))break}createPointerContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(t){const e=this.raycast();return{event:t,pointer:this._pointer.clone(),intersects:e,modelIntersects:this.filterIntersectsByLayer(e,h.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(e,h.UI_LAYER_MASK)}}updatePointer(t){this._pointer.x=t.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(t.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object)}updatePointerState(t,e){switch(t.button){case 0:this._pointerPrimaryDown=e;break;case 1:this._pointerMiddleDown=e;break;case 2:this._pointerSecondaryDown=e;break}}raycast(){this._raycaster.layers.mask=h.PRODUCT_LAYER_MASK|h.UI_LAYER_MASK;const t=this._scene.children.filter(e=>e.visible&&"isMesh"in e&&e.isMesh);return this._raycaster.intersectObjects(t,!0)}filterIntersectsByLayer(t,e){return t.filter(s=>(s.object.layers.mask&e)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((t,e)=>t.priority-e.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>E}}exports.DIVESelectTool=g;exports.DIVETransformTool=u;exports.DragTool=D;exports.HoverTool=b;exports.SelectTool=g;exports.SelectionState=m;exports.Toolbox=M;exports.TransformTool=u;exports.isSelectTool=P;exports.isTransformTool=w;
|
|
@@ -2,7 +2,7 @@ var S = Object.defineProperty;
|
|
|
2
2
|
var w = (n, t, e) => t in n ? S(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
3
|
var o = (n, t, e) => w(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { EventDispatcher as T, Vector3 as l, Raycaster as P, Vector2 as f, Layers as m } from "three/webgpu";
|
|
5
|
-
import "../../chunks/FileTypes-
|
|
5
|
+
import "../../chunks/FileTypes-DiYB3WBp.mjs";
|
|
6
6
|
import { P as _, U as d } from "../../chunks/PerspectiveCamera-B5TvUzTa.mjs";
|
|
7
7
|
import "three/examples/jsm/loaders/HDRLoader.js";
|
|
8
8
|
import "three/tsl";
|
|
@@ -395,22 +395,13 @@ class X {
|
|
|
395
395
|
o(this, "_boundPointerUp");
|
|
396
396
|
o(this, "_boundWheel");
|
|
397
397
|
this._scene = t, this._controller = e, this._canvas = e.domElement, this._selectionState = new z(), this._raycaster = new P(), this._pointer = new f(), this._lastPointerDown = new f(), this._productLayerMask = new m(), this._productLayerMask.set(Math.log2(_)), this._uiLayerMask = new m(), this._uiLayerMask.set(Math.log2(d)), this._tools = /* @__PURE__ */ new Map([
|
|
398
|
-
[
|
|
399
|
-
|
|
400
|
-
new C()
|
|
401
|
-
],
|
|
402
|
-
[
|
|
403
|
-
"select",
|
|
404
|
-
new M(this._selectionState)
|
|
405
|
-
],
|
|
398
|
+
["hover", new C()],
|
|
399
|
+
["select", new M(this._selectionState)],
|
|
406
400
|
[
|
|
407
401
|
"transform",
|
|
408
402
|
new L(t, e, this._selectionState)
|
|
409
403
|
],
|
|
410
|
-
[
|
|
411
|
-
"drag",
|
|
412
|
-
new j(e)
|
|
413
|
-
]
|
|
404
|
+
["drag", new j(e)]
|
|
414
405
|
]), this._boundPointerMove = this.onPointerMove.bind(this), this._boundPointerDown = this.onPointerDown.bind(this), this._boundPointerUp = this.onPointerUp.bind(this), this._boundWheel = this.onWheel.bind(this), this._canvas.addEventListener("pointermove", this._boundPointerMove), this._canvas.addEventListener("pointerdown", this._boundPointerDown), this._canvas.addEventListener("pointerup", this._boundPointerUp), this._canvas.addEventListener("wheel", this._boundWheel);
|
|
415
406
|
}
|
|
416
407
|
get selectionState() {
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { EntityTypeSchema } from './EntityTypeSchema.ts';
|
|
2
|
+
/** What every entity of a scene carries, whatever its type. */
|
|
2
3
|
export type BaseEntitySchema = {
|
|
4
|
+
/**
|
|
5
|
+
* Identifies the entity across the whole system: it keys the state's
|
|
6
|
+
* registry and is what a scene object carries in `userData.id`, which is
|
|
7
|
+
* how the two are matched up again.
|
|
8
|
+
*/
|
|
3
9
|
id: string;
|
|
10
|
+
/** Free text for the user interface, not used to look anything up. */
|
|
4
11
|
name: string;
|
|
12
|
+
/** Discriminates the union, see {@link EntityTypeSchema}. */
|
|
5
13
|
entityType: EntityTypeSchema;
|
|
6
14
|
visible: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The id of the group this entity hangs under, or `null` for the root.
|
|
17
|
+
*
|
|
18
|
+
* This is the one field where `null` carries meaning rather than standing
|
|
19
|
+
* for "not set". A parent that is not in the scene is ignored with a
|
|
20
|
+
* warning and the entity stays at the root.
|
|
21
|
+
*/
|
|
7
22
|
parentId?: string | null;
|
|
23
|
+
/** Blocks the entity from being moved through the toolbox. */
|
|
24
|
+
locked?: boolean;
|
|
8
25
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Vector3Like } from 'three/webgpu';
|
|
2
|
+
import { BaseEntitySchema } from './BaseEntitySchema.ts';
|
|
3
|
+
import { EntitySchema } from './EntitySchema.ts';
|
|
4
|
+
export declare function isCameraSchema(entity: EntitySchema): entity is CameraSchema;
|
|
5
|
+
/**
|
|
6
|
+
* A stored point of view that a user can jump to.
|
|
7
|
+
*
|
|
8
|
+
* Unlike the other entity types this creates nothing in the scene graph, it
|
|
9
|
+
* only lives in the state. Moving the camera there is the job of the camera
|
|
10
|
+
* actions, not of adding the entity.
|
|
11
|
+
*/
|
|
12
|
+
export type CameraSchema = BaseEntitySchema & {
|
|
13
|
+
entityType: 'camera';
|
|
14
|
+
/** Where the camera sits. */
|
|
15
|
+
position: Vector3Like;
|
|
16
|
+
/** What it looks at, which is also the point it orbits around. */
|
|
17
|
+
target: Vector3Like;
|
|
18
|
+
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CameraSchema } from './CameraSchema.ts';
|
|
2
2
|
import { LightSchema } from './LightSchema.ts';
|
|
3
3
|
import { ModelSchema } from './ModelSchema.ts';
|
|
4
4
|
import { PrimitiveSchema } from './PrimitiveSchema.ts';
|
|
5
5
|
import { GroupSchema } from './GroupSchema.ts';
|
|
6
|
-
export type MinimalSchema<T extends EntitySchema> = T extends EntitySchema ? {
|
|
6
|
+
export type MinimalSchema<T extends EntitySchema | void = void> = T extends EntitySchema ? {
|
|
7
7
|
id: string;
|
|
8
8
|
entityType: T['entityType'];
|
|
9
9
|
} : never;
|
|
10
|
+
/**
|
|
11
|
+
* A patch of an entity: the id and entity type identify what to change, every
|
|
12
|
+
* other field is optional.
|
|
13
|
+
*
|
|
14
|
+
* A missing field means "leave this as it is". There is no way to unset a field
|
|
15
|
+
* through a patch, and `null` is not a delete marker: it is only valid where a
|
|
16
|
+
* schema declares it and carries its own meaning there, as `parentId: null`
|
|
17
|
+
* does for "sits at the root". Consumers apply exactly the fields that are not
|
|
18
|
+
* `undefined` and pass everything else through untouched.
|
|
19
|
+
*/
|
|
10
20
|
export type PartialSchema<T extends EntitySchema | void = void> = T extends EntitySchema ? MinimalSchema<T> & Partial<T> : MinimalSchema<EntitySchema> & Partial<EntitySchema>;
|
|
11
|
-
export type EntitySchema =
|
|
21
|
+
export type EntitySchema = CameraSchema | LightSchema | ModelSchema | PrimitiveSchema | GroupSchema;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Discriminant of {@link EntitySchema}, and what decides which scene object an
|
|
3
|
+
* entity turns into.
|
|
4
|
+
*
|
|
5
|
+
* Everything but `camera` becomes an object in the scene graph. A camera is a
|
|
6
|
+
* stored point of view, so adding one registers it without creating anything
|
|
7
|
+
* to render, which is why an add can resolve without a scene object.
|
|
8
|
+
*/
|
|
9
|
+
export type EntityTypeSchema = 'camera' | 'light' | 'model' | 'primitive' | 'group';
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { GeometryTypeSchema } from './GeometryTypeSchema.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Describes the shape of a primitive.
|
|
4
|
+
*
|
|
5
|
+
* The three dimensions are a common denominator across all shapes rather than
|
|
6
|
+
* a bounding box, so each type reads only what it needs: a sphere derives its
|
|
7
|
+
* radius from `width` alone and ignores the other two, while a box uses all
|
|
8
|
+
* three.
|
|
9
|
+
*/
|
|
2
10
|
export type GeometrySchema = {
|
|
11
|
+
/** Picks the shape to build, see {@link GeometryTypeSchema}. */
|
|
3
12
|
name: GeometryTypeSchema;
|
|
4
13
|
width: number;
|
|
5
14
|
height: number;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes a primitive can take.
|
|
3
|
+
*
|
|
4
|
+
* `cube` and `box` build the same geometry. An unknown value is not an error,
|
|
5
|
+
* it only warns and leaves the primitive without a mesh.
|
|
6
|
+
*/
|
|
1
7
|
export type GeometryTypeSchema = 'cylinder' | 'sphere' | 'pyramid' | 'cube' | 'box' | 'cone' | 'wall' | 'plane';
|
|
@@ -2,10 +2,17 @@ import { Vector3Like } from 'three/webgpu';
|
|
|
2
2
|
import { BaseEntitySchema } from './BaseEntitySchema.ts';
|
|
3
3
|
import { EntitySchema } from './EntitySchema.ts';
|
|
4
4
|
export declare function isGroupSchema(entity: EntitySchema): entity is GroupSchema;
|
|
5
|
+
/**
|
|
6
|
+
* Holds other entities, which reference it through their `parentId`.
|
|
7
|
+
*
|
|
8
|
+
* Moving a group moves its members with it. Deleting one keeps the members
|
|
9
|
+
* alive: they are re-attached to the root and keep their world position.
|
|
10
|
+
*/
|
|
5
11
|
export type GroupSchema = BaseEntitySchema & {
|
|
6
12
|
entityType: 'group';
|
|
7
13
|
position: Vector3Like;
|
|
8
14
|
rotation: Vector3Like;
|
|
9
15
|
scale: Vector3Like;
|
|
16
|
+
/** Shows the helper lines that run from the group to each of its members. */
|
|
10
17
|
bbVisible?: boolean;
|
|
11
18
|
};
|
|
@@ -2,27 +2,43 @@ import { Vector3Like } from 'three/webgpu';
|
|
|
2
2
|
import { BaseEntitySchema } from './BaseEntitySchema.ts';
|
|
3
3
|
import { EntitySchema } from './EntitySchema.ts';
|
|
4
4
|
export declare function isLightSchema(entity: EntitySchema): entity is LightSchema;
|
|
5
|
+
/** What all lights share, regardless of their {@link LightTypeSchema}. */
|
|
5
6
|
export type BaseLightSchema = BaseEntitySchema & {
|
|
7
|
+
/** Discriminates the light union and picks the class to instantiate. */
|
|
6
8
|
type: LightTypeSchema;
|
|
7
9
|
intensity: number;
|
|
8
10
|
color: string | number;
|
|
11
|
+
/**
|
|
12
|
+
* Turns the light itself off while the entity stays in the scene, which is
|
|
13
|
+
* not the same as `visible` on the entity.
|
|
14
|
+
*/
|
|
9
15
|
enabled: boolean;
|
|
16
|
+
/** Optional here because only a point light is placed somewhere. */
|
|
10
17
|
position?: Vector3Like;
|
|
11
18
|
rotation?: Vector3Like;
|
|
12
19
|
};
|
|
20
|
+
/** Lights the whole scene evenly, so it has no position to speak of. */
|
|
13
21
|
export type AmbientLightSchema = BaseLightSchema & {
|
|
14
22
|
entityType: 'light';
|
|
15
23
|
type: 'ambient';
|
|
16
24
|
};
|
|
25
|
+
/** Radiates from one point, the only light type that needs a position. */
|
|
17
26
|
export type PointLightSchema = BaseLightSchema & {
|
|
18
27
|
entityType: 'light';
|
|
19
28
|
type: 'point';
|
|
20
29
|
position: Vector3Like;
|
|
21
30
|
};
|
|
31
|
+
/** The preset three point setup that DIVE ships as a default lighting. */
|
|
22
32
|
export type SceneLightSchema = BaseLightSchema & {
|
|
23
33
|
entityType: 'light';
|
|
24
34
|
type: 'scene';
|
|
25
35
|
};
|
|
26
36
|
type LightTypeSchema = 'ambient' | 'point' | 'scene';
|
|
37
|
+
/**
|
|
38
|
+
* A light in the scene.
|
|
39
|
+
*
|
|
40
|
+
* An unknown `type` is a hard error when the entity is added, because there is
|
|
41
|
+
* no sensible light to fall back to.
|
|
42
|
+
*/
|
|
27
43
|
export type LightSchema = AmbientLightSchema | PointLightSchema | SceneLightSchema;
|
|
28
44
|
export {};
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { Texture } from 'three/webgpu';
|
|
2
|
+
/**
|
|
3
|
+
* Surface properties of a model or primitive.
|
|
4
|
+
*
|
|
5
|
+
* Both carry this as a `Partial`, and a patch is merged into what is already
|
|
6
|
+
* there field by field. A nested field can therefore be overwritten but not
|
|
7
|
+
* removed again through an update.
|
|
8
|
+
*
|
|
9
|
+
* The `null` on the texture slots means "no texture", not "unchanged".
|
|
10
|
+
*/
|
|
2
11
|
export type MaterialSchema = {
|
|
3
12
|
vertexColors: boolean;
|
|
4
13
|
color: string | number;
|
|
14
|
+
/** The base colour texture. */
|
|
5
15
|
map: Texture | null;
|
|
6
16
|
normalMap: Texture | null;
|
|
7
17
|
roughness: number;
|
|
@@ -3,12 +3,28 @@ import { MaterialSchema } from './MaterialSchema.ts';
|
|
|
3
3
|
import { BaseEntitySchema } from './BaseEntitySchema.ts';
|
|
4
4
|
import { EntitySchema } from './EntitySchema.ts';
|
|
5
5
|
export declare function isModelSchema(entity: EntitySchema): entity is ModelSchema;
|
|
6
|
+
/**
|
|
7
|
+
* A 3D asset that is fetched from a uri, the only entity type whose creation
|
|
8
|
+
* involves a network round trip.
|
|
9
|
+
*/
|
|
6
10
|
export type ModelSchema = BaseEntitySchema & {
|
|
7
11
|
entityType: 'model';
|
|
12
|
+
/**
|
|
13
|
+
* Where the asset is loaded from.
|
|
14
|
+
*
|
|
15
|
+
* The uri is what identifies the loaded asset, so a patch that repeats the
|
|
16
|
+
* current one does not fetch anything again. Only a different uri triggers
|
|
17
|
+
* a reload, and adding or updating a model settles once that finished.
|
|
18
|
+
*/
|
|
8
19
|
uri: string;
|
|
9
20
|
position: Vector3Like;
|
|
10
21
|
rotation: Vector3Like;
|
|
11
22
|
scale: Vector3Like;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Never written or read. Whether an asset has arrived is
|
|
25
|
+
* signalled by the `MODEL_LOADED` action instead.
|
|
26
|
+
*/
|
|
12
27
|
loaded: boolean;
|
|
28
|
+
/** Overrides on top of what the asset itself brings along. */
|
|
13
29
|
material?: Partial<MaterialSchema>;
|
|
14
30
|
};
|
|
@@ -4,11 +4,16 @@ import { GeometrySchema } from './GeometrySchema.ts';
|
|
|
4
4
|
import { MaterialSchema } from './MaterialSchema.ts';
|
|
5
5
|
import { EntitySchema } from './EntitySchema.ts';
|
|
6
6
|
export declare function isPrimitiveSchema(entity: EntitySchema): entity is PrimitiveSchema;
|
|
7
|
+
/**
|
|
8
|
+
* A shape that DIVE generates itself, so unlike a model it needs no asset and
|
|
9
|
+
* is there the moment it is added.
|
|
10
|
+
*/
|
|
7
11
|
export type PrimitiveSchema = BaseEntitySchema & {
|
|
8
12
|
entityType: 'primitive';
|
|
9
13
|
position: Vector3Like;
|
|
10
14
|
rotation: Vector3Like;
|
|
11
15
|
scale: Vector3Like;
|
|
16
|
+
/** Rebuilding this replaces the mesh, see {@link GeometrySchema}. */
|
|
12
17
|
geometry: GeometrySchema;
|
|
13
18
|
material?: Partial<MaterialSchema>;
|
|
14
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware-ag/dive",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Shopware Spatial Framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/dive.cjs",
|
|
@@ -107,9 +107,8 @@
|
|
|
107
107
|
"> 1%, not dead, not ie 11, not op_mini all"
|
|
108
108
|
],
|
|
109
109
|
"dependencies": {
|
|
110
|
-
"three": "^0.
|
|
110
|
+
"three": "^0.185.1",
|
|
111
111
|
"@tweenjs/tween.js": "^25.0.0",
|
|
112
|
-
"three-spritetext": "^1.8.2",
|
|
113
112
|
"lodash": "^4.18.1",
|
|
114
113
|
"occt-import-js": "^0.0.23"
|
|
115
114
|
},
|
|
@@ -119,8 +118,8 @@
|
|
|
119
118
|
"@types/jest": "^29.5.12",
|
|
120
119
|
"@types/lodash": "^4.17.12",
|
|
121
120
|
"@types/node": "^20.12.7",
|
|
122
|
-
"@types/three": "^0.
|
|
123
|
-
"@vitest/coverage-v8": "3.
|
|
121
|
+
"@types/three": "^0.185.1",
|
|
122
|
+
"@vitest/coverage-v8": "3.2.7",
|
|
124
123
|
"acorn": "^8.14.1",
|
|
125
124
|
"acorn-walk": "^8.3.4",
|
|
126
125
|
"chokidar": "^3.6.0",
|
|
@@ -130,13 +129,11 @@
|
|
|
130
129
|
"jsdom": "^26.1.0",
|
|
131
130
|
"log-update": "^6.1.0",
|
|
132
131
|
"magic-string": "^0.30.17",
|
|
133
|
-
"prettier": "^3.
|
|
134
|
-
"prettier-plugin-multiline-arrays": "^3.0.6",
|
|
132
|
+
"prettier": "^3.9.6",
|
|
135
133
|
"rollup-plugin-copy": "^3.5.0",
|
|
136
134
|
"ts-jest": "^29.1.2",
|
|
137
135
|
"ts-morph": "^25.0.1",
|
|
138
136
|
"ts-node": "^10.9.2",
|
|
139
|
-
"tsc": "^2.0.4",
|
|
140
137
|
"tsx": "^4.19.4",
|
|
141
138
|
"typescript": "^5.8.2",
|
|
142
139
|
"typescript-eslint": "^7.7.1",
|
|
@@ -148,7 +145,9 @@
|
|
|
148
145
|
},
|
|
149
146
|
"resolutions": {
|
|
150
147
|
"lodash": "4.18.1",
|
|
151
|
-
"vite-plugin-dts/@microsoft/api-extractor/minimatch": "3.1.5"
|
|
148
|
+
"vite-plugin-dts/@microsoft/api-extractor/minimatch": "3.1.5",
|
|
149
|
+
"minimatch/brace-expansion": "1.1.16",
|
|
150
|
+
"fast-uri": "^3.1.5"
|
|
152
151
|
},
|
|
153
152
|
"scripts": {
|
|
154
153
|
"build": "vite build",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function t(e){return e.entityType==="model"}function i(e){return e.entityType==="pov"}exports.isModelSchema=t;exports.isPovSchema=i;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Vector3Like } from 'three/webgpu';
|
|
2
|
-
import { BaseEntitySchema } from './BaseEntitySchema.ts';
|
|
3
|
-
import { EntitySchema } from './EntitySchema.ts';
|
|
4
|
-
export declare function isPovSchema(entity: EntitySchema): entity is PovSchema;
|
|
5
|
-
export type PovSchema = BaseEntitySchema & {
|
|
6
|
-
entityType: 'pov';
|
|
7
|
-
position: Vector3Like;
|
|
8
|
-
target: Vector3Like;
|
|
9
|
-
locked?: boolean;
|
|
10
|
-
};
|