@shopware-ag/dive
Advanced tools
Comparing version 1.16.5 to 1.16.6
@@ -615,8 +615,11 @@ import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Object3D, Color, Mesh, ColorRepresentation, Intersection, Vector2, Raycaster, Vector3 } from 'three'; | ||
id: string; | ||
entityType: string; | ||
}): void; | ||
DeleteSceneObject(object: Partial<COMEntity> & { | ||
id: string; | ||
entityType: string; | ||
}): void; | ||
PlaceOnFloor(object: Partial<COMEntity> & { | ||
id: string; | ||
entityType: string; | ||
}): void; | ||
@@ -684,8 +687,11 @@ private updateLight; | ||
id: string; | ||
entityType: string; | ||
}): void; | ||
DeleteSceneObject(object: Partial<COMEntity> & { | ||
id: string; | ||
entityType: string; | ||
}): void; | ||
PlaceOnFloor(object: Partial<COMModel> & { | ||
id: string; | ||
entityType: string; | ||
}): void; | ||
@@ -692,0 +698,0 @@ } |
{ | ||
"name": "@shopware-ag/dive", | ||
"version": "1.16.5", | ||
"version": "1.16.6", | ||
"description": "Shopware Spatial Framework", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -211,2 +211,10 @@ import DIVE, { DIVESettings } from '../dive.ts'; | ||
it('should instantiate in development NODE_ENV', () => { | ||
process.env.NODE_ENV = 'development'; | ||
const dive = new DIVE(); | ||
expect(dive).toBeDefined(); | ||
expect((window as any).DIVE.PrintScene).toBeDefined(); | ||
expect(() => (window as any).DIVE.PrintScene()).not.toThrow(); | ||
}); | ||
it('should dispose', () => { | ||
@@ -213,0 +221,0 @@ let dive = new DIVE(); |
@@ -519,5 +519,6 @@ import { Actions } from './actions/index.ts'; | ||
): Actions['PLACE_ON_FLOOR']['RETURN'] { | ||
if (!this.registered.get(payload.id)) return false; | ||
const object = this.registered.get(payload.id); | ||
if (!object) return false; | ||
this.scene.PlaceOnFloor(payload); | ||
this.scene.PlaceOnFloor(object); | ||
@@ -524,0 +525,0 @@ return true; |
@@ -231,6 +231,10 @@ import { DIVEModel } from '../Model'; | ||
const spy = jest.spyOn(model, 'onMove').mockImplementation(() => {}); | ||
expect(() => model.PlaceOnFloor()).not.toThrow(); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined); | ||
expect(() => model.PlaceOnFloor()).not.toThrow(); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
}); | ||
@@ -244,2 +248,4 @@ | ||
const spy = jest.spyOn(model, 'onMove').mockImplementation(() => {}); | ||
const size = { | ||
@@ -289,12 +295,12 @@ x: 1, | ||
expect(model.position.y).toBe(2.5); | ||
expect(comMock.PerformAction).toHaveBeenCalledTimes(1); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
expect(() => model.DropIt()).not.toThrow(); | ||
expect(comMock.PerformAction).toHaveBeenCalledTimes(1); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
// reset for PerformAction to be called again | ||
// alter position so onMove will be called again | ||
model.position.y = 2; | ||
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined); | ||
expect(() => model.DropIt()).not.toThrow(); | ||
expect(comMock.PerformAction).toHaveBeenCalledTimes(1); | ||
expect(spy).toHaveBeenCalledTimes(2); | ||
}); | ||
@@ -301,0 +307,0 @@ |
import { Mesh, MeshStandardMaterial, Raycaster, Vector3 } from 'three'; | ||
import { PRODUCT_LAYER_MASK } from '../constant/VisibilityLayerMask'; | ||
import { DIVECommunication } from '../com/Communication'; | ||
import type { GLTF } from 'three/examples/jsm/Addons.js'; | ||
@@ -114,12 +113,7 @@ import { findSceneRecursive } from '../helper/findSceneRecursive/findSceneRecursive'; | ||
public PlaceOnFloor(): void { | ||
const oldPos = this.position.clone(); | ||
this.position.y = -this._boundingBox.min.y * this.scale.y; | ||
DIVECommunication.get(this.userData.id)?.PerformAction( | ||
'UPDATE_OBJECT', | ||
{ | ||
id: this.userData.id, | ||
position: this.position, | ||
rotation: this.rotation, | ||
scale: this.scale, | ||
}, | ||
); | ||
if (this.position.y === oldPos.y) return; | ||
this.onMove(); | ||
} | ||
@@ -167,13 +161,6 @@ | ||
if (this.position.y === oldPos.y) return; | ||
DIVECommunication.get(this.userData.id)?.PerformAction( | ||
'UPDATE_OBJECT', | ||
{ | ||
id: this.userData.id, | ||
position: this.position, | ||
rotation: this.rotation, | ||
scale: this.scale, | ||
}, | ||
); | ||
this.onMove(); | ||
} | ||
} | ||
} |
@@ -258,2 +258,6 @@ import { DIVEPrimitive } from '../Primitive'; | ||
const spy = jest | ||
.spyOn(primitive, 'onMove') | ||
.mockImplementation(() => {}); | ||
const size = { | ||
@@ -303,12 +307,12 @@ x: 1, | ||
expect(primitive.position.y).toBe(2.5); | ||
expect(comMock.PerformAction).toHaveBeenCalledTimes(1); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
expect(() => primitive.DropIt()).not.toThrow(); | ||
expect(comMock.PerformAction).toHaveBeenCalledTimes(1); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
// reset for PerformAction to be called again | ||
// alter position so onMove will be called again | ||
primitive.position.y = 2; | ||
jest.spyOn(DIVECommunication, 'get').mockReturnValueOnce(undefined); | ||
expect(() => primitive.DropIt()).not.toThrow(); | ||
expect(comMock.PerformAction).toHaveBeenCalledTimes(1); | ||
expect(spy).toHaveBeenCalledTimes(2); | ||
}); | ||
@@ -315,0 +319,0 @@ |
@@ -13,3 +13,2 @@ import { | ||
} from 'three'; | ||
import { DIVECommunication } from '../com/Communication'; | ||
import { PRODUCT_LAYER_MASK } from '../constant/VisibilityLayerMask'; | ||
@@ -111,12 +110,7 @@ import { findSceneRecursive } from '../helper/findSceneRecursive/findSceneRecursive'; | ||
public PlaceOnFloor(): void { | ||
const oldPos = this.position.clone(); | ||
this.position.y = -this._boundingBox.min.y * this.scale.y; | ||
DIVECommunication.get(this.userData.id)?.PerformAction( | ||
'UPDATE_OBJECT', | ||
{ | ||
id: this.userData.id, | ||
position: this.position, | ||
rotation: this.rotation, | ||
scale: this.scale, | ||
}, | ||
); | ||
if (this.position.y === oldPos.y) return; | ||
this.onMove(); | ||
} | ||
@@ -164,11 +158,4 @@ | ||
if (this.position.y === oldPos.y) return; | ||
DIVECommunication.get(this.userData.id)?.PerformAction( | ||
'UPDATE_OBJECT', | ||
{ | ||
id: this.userData.id, | ||
position: this.position, | ||
rotation: this.rotation, | ||
scale: this.scale, | ||
}, | ||
); | ||
this.onMove(); | ||
} | ||
@@ -175,0 +162,0 @@ } |
@@ -416,4 +416,2 @@ import { DIVERoot } from '../Root'; | ||
jest.spyOn(console, 'warn').mockImplementation(() => {}); | ||
describe('DIVE/scene/root/DIVERoot', () => { | ||
@@ -718,2 +716,18 @@ beforeEach(() => { | ||
).not.toThrow(); | ||
jest.spyOn(console, 'warn').mockImplementationOnce(() => {}); | ||
expect(() => | ||
root.UpdateSceneObject({ | ||
entityType: 'INVALID' as COMEntityType, | ||
} as COMPrimitive), | ||
).not.toThrow(); | ||
expect(console.warn).toHaveBeenCalled(); | ||
jest.spyOn(console, 'warn').mockImplementationOnce(() => {}); | ||
expect(() => | ||
root.UpdateSceneObject({ | ||
entityType: undefined, | ||
} as unknown as COMPrimitive), | ||
).not.toThrow(); | ||
expect(console.warn).toHaveBeenCalled(); | ||
}); | ||
@@ -851,2 +865,18 @@ | ||
).not.toThrow(); | ||
jest.spyOn(console, 'warn').mockImplementationOnce(() => {}); | ||
expect(() => | ||
root.DeleteSceneObject({ | ||
entityType: 'INVALID' as COMEntityType, | ||
} as COMPrimitive), | ||
).not.toThrow(); | ||
expect(console.warn).toHaveBeenCalled(); | ||
jest.spyOn(console, 'warn').mockImplementationOnce(() => {}); | ||
expect(() => | ||
root.DeleteSceneObject({ | ||
entityType: undefined, | ||
} as unknown as COMPrimitive), | ||
).not.toThrow(); | ||
expect(console.warn).toHaveBeenCalled(); | ||
}); | ||
@@ -934,6 +964,24 @@ | ||
).not.toThrow(); | ||
jest.spyOn(console, 'warn').mockImplementationOnce(() => {}); | ||
expect(() => | ||
root.PlaceOnFloor({ | ||
entityType: 'INVALID' as COMEntityType, | ||
} as COMPrimitive), | ||
).not.toThrow(); | ||
expect(console.warn).toHaveBeenCalled(); | ||
jest.spyOn(console, 'warn').mockImplementationOnce(() => {}); | ||
expect(() => | ||
root.PlaceOnFloor({ | ||
entityType: undefined, | ||
} as unknown as COMPrimitive), | ||
).not.toThrow(); | ||
expect(console.warn).toHaveBeenCalled(); | ||
}); | ||
it('should warn if entity type is invalid while adding object', () => { | ||
const spy = jest.spyOn(console, 'warn').mockImplementation(() => {}); | ||
const spy = jest | ||
.spyOn(console, 'warn') | ||
.mockImplementationOnce(() => {}); | ||
expect(() => | ||
@@ -951,3 +999,5 @@ root.AddSceneObject({ | ||
it('should warn if entity type is invalid while updating object', () => { | ||
const spy = jest.spyOn(console, 'warn').mockImplementation(() => {}); | ||
const spy = jest | ||
.spyOn(console, 'warn') | ||
.mockImplementationOnce(() => {}); | ||
expect(() => | ||
@@ -965,3 +1015,5 @@ root.UpdateSceneObject({ | ||
it('should warn if entity type is invalid while deleting object', () => { | ||
const spy = jest.spyOn(console, 'warn').mockImplementation(() => {}); | ||
const spy = jest | ||
.spyOn(console, 'warn') | ||
.mockImplementationOnce(() => {}); | ||
expect(() => | ||
@@ -979,3 +1031,5 @@ root.DeleteSceneObject({ | ||
it('should warn if entity type is invalid while placing on floor', () => { | ||
const spy = jest.spyOn(console, 'warn').mockImplementation(() => {}); | ||
const spy = jest | ||
.spyOn(console, 'warn') | ||
.mockImplementationOnce(() => {}); | ||
expect(() => | ||
@@ -982,0 +1036,0 @@ root.PlaceOnFloor({ |
@@ -69,3 +69,3 @@ import { Box3, Color, Object3D } from 'three'; | ||
case 'light': { | ||
this.updateLight(object); | ||
this.updateLight(object as COMLight); | ||
break; | ||
@@ -94,3 +94,3 @@ } | ||
public UpdateSceneObject( | ||
object: Partial<COMEntity> & { id: string }, | ||
object: Partial<COMEntity> & { id: string; entityType: string }, | ||
): void { | ||
@@ -102,3 +102,3 @@ switch (object.entityType) { | ||
case 'light': { | ||
this.updateLight(object); | ||
this.updateLight(object as COMLight); | ||
break; | ||
@@ -127,3 +127,3 @@ } | ||
public DeleteSceneObject( | ||
object: Partial<COMEntity> & { id: string }, | ||
object: Partial<COMEntity> & { id: string; entityType: string }, | ||
): void { | ||
@@ -158,3 +158,5 @@ switch (object.entityType) { | ||
public PlaceOnFloor(object: Partial<COMEntity> & { id: string }): void { | ||
public PlaceOnFloor( | ||
object: Partial<COMEntity> & { id: string; entityType: string }, | ||
): void { | ||
switch (object.entityType) { | ||
@@ -178,3 +180,9 @@ case 'pov': | ||
private updateLight(light: Partial<COMLight> & { id: string }): void { | ||
private updateLight( | ||
light: Partial<COMLight> & { | ||
id: string; | ||
entityType: string; | ||
type: string; | ||
}, | ||
): void { | ||
let sceneObject = this.GetSceneObject(light); | ||
@@ -181,0 +189,0 @@ if (!sceneObject) { |
@@ -67,3 +67,3 @@ import { Color, Scene, type Box3, type ColorRepresentation } from 'three'; | ||
public UpdateSceneObject( | ||
object: Partial<COMEntity> & { id: string }, | ||
object: Partial<COMEntity> & { id: string; entityType: string }, | ||
): void { | ||
@@ -74,3 +74,3 @@ this.Root.UpdateSceneObject(object); | ||
public DeleteSceneObject( | ||
object: Partial<COMEntity> & { id: string }, | ||
object: Partial<COMEntity> & { id: string; entityType: string }, | ||
): void { | ||
@@ -80,5 +80,7 @@ this.Root.DeleteSceneObject(object); | ||
public PlaceOnFloor(object: Partial<COMModel> & { id: string }): void { | ||
public PlaceOnFloor( | ||
object: Partial<COMModel> & { id: string; entityType: string }, | ||
): void { | ||
this.Root.PlaceOnFloor(object); | ||
} | ||
} |
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
1065933
18924