@shopware-ag/dive
Advanced tools
Comparing version 1.15.4 to 1.15.5
@@ -214,5 +214,3 @@ import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Object3D, Color, Mesh, ColorRepresentation, Intersection, Vector2, Raycaster, Vector3 } from 'three'; | ||
visible: boolean; | ||
parent?: Partial<COMBaseEntity> & { | ||
id: string; | ||
} | null; | ||
parentId?: string | null; | ||
}; | ||
@@ -219,0 +217,0 @@ |
{ | ||
"name": "@shopware-ag/dive", | ||
"version": "1.15.4", | ||
"version": "1.15.5", | ||
"description": "Shopware Spatial Framework", | ||
@@ -33,2 +33,3 @@ "type": "module", | ||
"@tweenjs/tween.js": "^23.1.1", | ||
"lodash": "^4.17.21", | ||
"three": "^0.163.0", | ||
@@ -40,2 +41,3 @@ "three-spritetext": "^1.8.2" | ||
"@types/jest": "^29.5.12", | ||
"@types/lodash": "^4.17.12", | ||
"@types/node": "^20.12.7", | ||
@@ -42,0 +44,0 @@ "@types/three": "^0.163.0", |
@@ -524,3 +524,3 @@ import { DIVECommunication } from '../Communication'; | ||
rotation: { x: 0, y: 0, z: 0 }, | ||
parent: null, | ||
parentId: null, | ||
} as COMGroup); | ||
@@ -536,3 +536,3 @@ | ||
target: { x: 0, y: 0, z: 0 }, | ||
parent: null, | ||
parentId: null, | ||
}], | ||
@@ -547,3 +547,3 @@ floorColor: "#ffffff", | ||
color: 'white', | ||
parent: null, | ||
parentId: null, | ||
}], | ||
@@ -558,3 +558,3 @@ mediaItem: null, | ||
scale: { x: 0.01, y: 0.01, z: 0.01 }, | ||
parent: null, | ||
parentId: null, | ||
uri: "https://threejs.org/examples/models/gltf/LittlestTokyo.glb", | ||
@@ -573,3 +573,3 @@ }], | ||
rotation: { x: 0, y: 0, z: 0 }, | ||
parent: null, | ||
parentId: null, | ||
}], | ||
@@ -600,3 +600,3 @@ }); | ||
const successWithIds = testCom.PerformAction('GET_OBJECTS', { ids: ['test1'] }); | ||
expect(Array.from(successWithIds.values())).toStrictEqual([{ entityType: "pov", id: "test1", position: { x: 0, y: 0, z: 0 }, target: { x: 0, y: 0, z: 0 }, parent: null }]); | ||
expect(Array.from(successWithIds.values())).toStrictEqual([{ entityType: "pov", id: "test1", position: { x: 0, y: 0, z: 0 }, target: { x: 0, y: 0, z: 0 }, parentId: null }]); | ||
}); | ||
@@ -603,0 +603,0 @@ |
import { Actions } from "./actions/index.ts"; | ||
import { generateUUID } from 'three/src/math/MathUtils'; | ||
import { isSelectTool } from "../toolbox/select/SelectTool.ts"; | ||
import { merge } from 'lodash'; | ||
@@ -269,3 +270,3 @@ // type imports | ||
if (payload.parent === undefined) payload.parent = null; | ||
if (payload.parentId === undefined) payload.parentId = null; | ||
@@ -283,3 +284,3 @@ this.registered.set(payload.id, payload); | ||
this.registered.set(payload.id, { ...objectToUpdate, ...payload }); | ||
this.registered.set(payload.id, merge(objectToUpdate, payload)); | ||
@@ -286,0 +287,0 @@ const updatedObject = this.registered.get(payload.id)!; |
@@ -8,3 +8,3 @@ import { COMEntityType } from "./COMEntityType"; | ||
visible: boolean; | ||
parent?: Partial<COMBaseEntity> & { id: string } | null; | ||
parentId?: string | null; | ||
} |
@@ -13,2 +13,3 @@ import { DIVERenderer, DIVERendererDefaultSettings, DIVERendererSettings } from "./renderer/Renderer.ts"; | ||
import { DIVEInfo } from "./info/Info.ts"; | ||
import pkgjson from '../package.json'; | ||
@@ -231,3 +232,3 @@ export type DIVESettings = { | ||
console.log('DIVE initialized'); | ||
console.log(`DIVE ${pkgjson.version} initialized`); | ||
} | ||
@@ -234,0 +235,0 @@ |
@@ -212,4 +212,6 @@ import { DIVEPrimitive } from '../Primitive'; | ||
it('should set geometry', () => { | ||
const bufferGeometry = {} as COMGeometry; | ||
expect(() => primitive.SetGeometry(bufferGeometry)).not.toThrow(); | ||
const geometry = { | ||
name: 'geometry', | ||
} as COMGeometry; | ||
expect(() => primitive.SetGeometry(geometry)).not.toThrow(); | ||
}); | ||
@@ -216,0 +218,0 @@ |
@@ -102,3 +102,3 @@ import { BoxGeometry, BufferGeometry, Color, ConeGeometry, CylinderGeometry, Mesh, MeshStandardMaterial, Raycaster, SphereGeometry, Vector3 } from 'three'; | ||
if (!this.parent) { | ||
console.warn('DIVEModel: DropIt() called on a model that is not in the scene.', this); | ||
console.warn('DIVEPrimitive: DropIt() called on a model that is not in the scene.', this); | ||
return; | ||
@@ -135,3 +135,3 @@ } | ||
private assembleGeometry(geometry: COMGeometry): BufferGeometry { | ||
switch (geometry.name) { | ||
switch (geometry.name.toLowerCase()) { | ||
case 'cylinder': | ||
@@ -151,4 +151,6 @@ return this.createCylinderGeometry(geometry); | ||
return this.createPlaneGeometry(geometry); | ||
default: | ||
default: { | ||
console.warn('DIVEPrimitive: Invalid geometry type:', geometry.name.toLowerCase()); | ||
return new BufferGeometry(); | ||
} | ||
} | ||
@@ -155,0 +157,0 @@ } |
@@ -444,3 +444,3 @@ import { DIVERoot } from '../Root'; | ||
visible: true, | ||
parent: null, | ||
parentId: null, | ||
})).not.toThrow(); | ||
@@ -461,7 +461,7 @@ root.children = [{ | ||
expect(() => root.AddSceneObject({ id: 'id_ambient', name: 'light', entityType: 'light', visible: true, type: 'ambient' } as COMLight)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id_point', name: 'light', entityType: 'light', visible: true, type: 'point', position: { x: 0, y: 0, z: 0 }, intensity: 1, enabled: false, color: 0xffffff, parent: { id: 'id' } } as COMLight)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id_point', name: 'light', entityType: 'light', visible: true, type: 'point', position: { x: 0, y: 0, z: 0 }, intensity: 1, enabled: false, color: 0xffffff, parentId: 'id' } as COMLight)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id', name: 'model', entityType: 'model', visible: true } as COMModel)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id_uri0', name: 'model', entityType: 'model', visible: true, uri: 'uri', position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 }, scale: { x: 1, y: 1, z: 1 }, material: {}, parent: { id: 'id' } } as COMModel)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id_uri0', name: 'model', entityType: 'model', visible: true, uri: 'uri', position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 }, scale: { x: 1, y: 1, z: 1 }, material: {}, parentId: 'id' } as COMModel)).not.toThrow(); | ||
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined); | ||
@@ -471,6 +471,6 @@ expect(() => root.AddSceneObject({ id: 'id_uri1', name: 'model', entityType: 'model', visible: true, uri: 'uri', position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 }, scale: { x: 1, y: 1, z: 1 }, material: {} } as COMModel)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id0', name: 'primitive', entityType: 'primitive', visible: true } as COMPrimitive)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id1', name: 'primitive', entityType: 'primitive', visible: true, material: {}, parent: { id: 'id' } } as COMPrimitive)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id1', name: 'primitive', entityType: 'primitive', visible: true, material: {}, parentId: 'id' } as COMPrimitive)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id0', name: 'Group', entityType: 'group', visible: true } as COMGroup)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id0', name: 'Group', entityType: 'group', visible: true, position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 }, scale: { x: 1, y: 1, z: 1 }, bbVisible: true, parent: { id: 'id' } } as COMGroup)).not.toThrow(); | ||
expect(() => root.AddSceneObject({ id: 'id0', name: 'Group', entityType: 'group', visible: true, position: { x: 0, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 }, scale: { x: 1, y: 1, z: 1 }, bbVisible: true, parentId: 'id' } as COMGroup)).not.toThrow(); | ||
}); | ||
@@ -523,6 +523,6 @@ | ||
expect(() => root.AddSceneObject({ id: 'id_groupparent', name: 'Group', entityType: 'group' } as COMGroup)).not.toThrow(); | ||
expect(() => root.UpdateSceneObject({ id: 'id_groupchild', name: 'group', entityType: 'group', parent: { id: 'id_groupparent' } } as COMGroup)).not.toThrow(); | ||
expect(() => root.UpdateSceneObject({ id: 'id_groupchild', name: 'group', entityType: 'group', parent: null } as COMGroup)).not.toThrow(); | ||
expect(() => root.UpdateSceneObject({ id: 'id_groupchild', name: 'group', entityType: 'group', parent: { id: 'id_modelparent' } } as COMGroup)).not.toThrow(); | ||
expect(() => root.UpdateSceneObject({ id: 'id_groupchild', name: 'group', entityType: 'group', parent: { id: 'does_not_exist' } } as COMGroup)).not.toThrow(); | ||
expect(() => root.UpdateSceneObject({ id: 'id_groupchild', name: 'group', entityType: 'group', parentId: 'id_groupparent' } as COMGroup)).not.toThrow(); | ||
expect(() => root.UpdateSceneObject({ id: 'id_groupchild', name: 'group', entityType: 'group', parentId: null } as COMGroup)).not.toThrow(); | ||
expect(() => root.UpdateSceneObject({ id: 'id_groupchild', name: 'group', entityType: 'group', parentId: 'id_modelparent' } as COMGroup)).not.toThrow(); | ||
expect(() => root.UpdateSceneObject({ id: 'id_groupchild', name: 'group', entityType: 'group', parentId: 'does_not_exist' } as COMGroup)).not.toThrow(); | ||
}); | ||
@@ -529,0 +529,0 @@ |
@@ -160,3 +160,3 @@ import { Box3, Color, Object3D } from "three"; | ||
default: { | ||
console.warn(`Root.updateLight: Unknown light type: ${light.type}`); | ||
console.warn(`DIVERoot.updateLight: Unknown light type: ${light.type}`); | ||
return; | ||
@@ -175,3 +175,3 @@ } | ||
if (light.visible !== undefined && light.visible !== null) (sceneObject as (DIVEAmbientLight | DIVEPointLight)).visible = light.visible; | ||
if (light.parent !== undefined) this.setParent({ ...light, parent: light.parent }); | ||
if (light.parentId !== undefined) this.setParent({ ...light, parentId: light.parentId }); | ||
} | ||
@@ -201,3 +201,3 @@ | ||
if (model.material !== undefined) (sceneObject as DIVEModel).SetMaterial(model.material); | ||
if (model.parent !== undefined) this.setParent({ ...model, parent: model.parent }); | ||
if (model.parentId !== undefined) this.setParent({ ...model, parentId: model.parentId }); | ||
} | ||
@@ -221,3 +221,3 @@ | ||
if (primitive.material !== undefined) (sceneObject as DIVEPrimitive).SetMaterial(primitive.material); | ||
if (primitive.parent !== undefined) this.setParent({ ...primitive, parent: primitive.parent }); | ||
if (primitive.parentId !== undefined) this.setParent({ ...primitive, parentId: primitive.parentId }); | ||
} | ||
@@ -240,3 +240,3 @@ | ||
if (group.bbVisible !== undefined) (sceneObject as DIVEGroup).SetLinesVisibility(group.bbVisible); | ||
if (group.parent !== undefined) this.setParent({ ...group, parent: group.parent }); | ||
if (group.parentId !== undefined) this.setParent({ ...group, parentId: group.parentId }); | ||
} | ||
@@ -247,3 +247,3 @@ | ||
if (!sceneObject) { | ||
console.warn(`Root.deleteLight: Light with id ${light.id} not found`); | ||
console.warn(`DIVERoot.deleteLight: Light with id ${light.id} not found`); | ||
return; | ||
@@ -260,3 +260,3 @@ } | ||
if (!sceneObject) { | ||
console.warn(`Root.deleteModel: Model with id ${model.id} not found`); | ||
console.warn(`DIVERoot.deleteModel: Model with id ${model.id} not found`); | ||
return; | ||
@@ -273,3 +273,3 @@ } | ||
if (!sceneObject) { | ||
console.warn(`Root.deletePrimitive: Primitive with id ${primitive.id} not found`); | ||
console.warn(`DIVERoot.deletePrimitive: Primitive with id ${primitive.id} not found`); | ||
return; | ||
@@ -286,3 +286,3 @@ } | ||
if (!sceneObject) { | ||
console.warn(`Root.deleteGroup: Group with id ${group.id} not found`); | ||
console.warn(`DIVERoot.deleteGroup: Group with id ${group.id} not found`); | ||
return; | ||
@@ -307,12 +307,8 @@ } | ||
private setParent(object: Partial<COMEntity> & { id: string, parent: (Partial<COMEntity> & { id: string }) | null }): void { | ||
private setParent(object: Partial<COMEntity> & { id: string, parentId: string | null }): void { | ||
const sceneObject = this.GetSceneObject<DIVESceneObject>(object); | ||
if (!sceneObject) return; | ||
if (sceneObject.parent) { | ||
sceneObject.parent.remove(sceneObject); | ||
} | ||
if (object.parent !== null) { | ||
const parent = this.GetSceneObject<DIVESceneObject>(object.parent); | ||
if (object.parentId !== null) { | ||
const parent = this.GetSceneObject<DIVESceneObject>({ id: object.parentId }); | ||
if (!parent) return; | ||
@@ -319,0 +315,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
961451
15204
4
15
+ Addedlodash@^4.17.21
+ Addedlodash@4.17.21(transitive)