@shopware-ag/dive
Advanced tools
Comparing version 1.12.0 to 1.12.1
@@ -789,2 +789,2 @@ import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Mesh, ColorRepresentation, Object3D, Intersection, Vector2, Raycaster, Vector3 } from 'three'; | ||
export { type Actions, type COMEntity, type COMLight, type COMModel, type COMPov, DIVE, DIVECommunication, DIVEDefaultSettings, DIVEMath, type DIVESettings, DIVE as default }; | ||
export { type Actions, type COMEntity, type COMLight, type COMModel, type COMPov, type COMPrimitive, DIVE, DIVECommunication, DIVEDefaultSettings, DIVEMath, type DIVESettings, DIVE as default }; |
{ | ||
"name": "@shopware-ag/dive", | ||
"version": "1.12.0", | ||
"version": "1.12.1", | ||
"description": "Shopware Spatial Framework", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -12,3 +12,3 @@ import { DIVERenderer, DIVERendererDefaultSettings, DIVERendererSettings } from "./renderer/Renderer.ts"; | ||
import type { Actions } from './com/actions/index.ts'; | ||
import type { COMPov, COMLight, COMModel, COMEntity } from './com/types.ts'; | ||
import type { COMPov, COMLight, COMModel, COMEntity, COMPrimitive } from './com/types.ts'; | ||
import { DIVEMath } from './math/index.ts'; | ||
@@ -282,2 +282,3 @@ import { generateUUID } from "three/src/math/MathUtils"; | ||
COMModel, | ||
COMPrimitive, | ||
COMEntity, | ||
@@ -284,0 +285,0 @@ }; |
@@ -142,21 +142,27 @@ import { DIVEPrimitive } from '../Primitive'; | ||
this.setIndex = jest.fn(); | ||
this.translate = jest.fn(); | ||
return this; | ||
}), | ||
CylinderGeometry: jest.fn(function () { | ||
return {}; | ||
this.translate = jest.fn(); | ||
return this; | ||
}), | ||
SphereGeometry: jest.fn(function () { | ||
return {}; | ||
this.translate = jest.fn(); | ||
return this; | ||
}), | ||
BoxGeometry: jest.fn(function () { | ||
return {}; | ||
this.translate = jest.fn(); | ||
return this; | ||
}), | ||
ConeGeometry: jest.fn(function () { | ||
return {}; | ||
this.rotateY = jest.fn(); | ||
this.translate = jest.fn(); | ||
return this; | ||
}), | ||
Float32BufferAttribute: jest.fn(function () { | ||
return {}; | ||
return this; | ||
}), | ||
Uint32BufferAttribute: jest.fn(function () { | ||
return {}; | ||
return this; | ||
}), | ||
@@ -394,2 +400,9 @@ MeshStandardMaterial: jest.fn(function () { | ||
const wallWithoutDepth = { | ||
name: 'wall', | ||
width: 1, | ||
height: 1.5, | ||
} as COMGeometry; | ||
expect(() => primitive.SetGeometry(wallWithoutDepth)).not.toThrow(); | ||
// plane | ||
@@ -412,2 +425,3 @@ const plane = { | ||
expect(() => primitive.SetMaterial({ | ||
@@ -418,10 +432,12 @@ color: 0xffffff, | ||
} as COMMaterial)).not.toThrow(); | ||
expect(material.roughness).toBe(0); | ||
expect(material.roughnessMap).toBeUndefined(); | ||
expect(material.metalness).toBe(1); | ||
expect(material.metalnessMap).toBeUndefined(); | ||
expect((material as MeshStandardMaterial).roughness).toBe(0); | ||
expect((material as MeshStandardMaterial).roughnessMap).toBeUndefined(); | ||
expect((material as MeshStandardMaterial).metalness).toBe(1); | ||
expect((material as MeshStandardMaterial).metalnessMap).toBeUndefined(); | ||
expect(() => primitive.SetMaterial({ | ||
color: 0xff00ff, | ||
vertexColors: true, | ||
map: 'This_Is_A_Texture' as unknown as Texture, | ||
normalMap: 'This_Is_A_Texture' as unknown as Texture, | ||
roughness: 0, | ||
@@ -432,7 +448,7 @@ roughnessMap: 'This_Is_A_Texture' as unknown as Texture, | ||
} as COMMaterial)).not.toThrow(); | ||
expect(material.roughness).toBe(1); | ||
expect(material.roughnessMap).toBeDefined(); | ||
expect(material.metalness).toBe(1); | ||
expect(material.metalnessMap).toBeDefined(); | ||
expect((material as MeshStandardMaterial).roughness).toBe(1); | ||
expect((material as MeshStandardMaterial).roughnessMap).toBeDefined(); | ||
expect((material as MeshStandardMaterial).metalness).toBe(0); | ||
expect((material as MeshStandardMaterial).metalnessMap).toBeDefined(); | ||
}); | ||
}); |
@@ -1,2 +0,2 @@ | ||
import { Box3, BoxGeometry, BufferGeometry, Color, CylinderGeometry, Float32BufferAttribute, Mesh, MeshStandardMaterial, Object3D, Raycaster, SphereGeometry, Uint32BufferAttribute, Vector3, Vector3Like } from 'three'; | ||
import { Box3, BoxGeometry, BufferGeometry, Color, ConeGeometry, CylinderGeometry, Mesh, MeshStandardMaterial, Object3D, Raycaster, SphereGeometry, Vector3, Vector3Like } from 'three'; | ||
import DIVECommunication from '../com/Communication'; | ||
@@ -38,2 +38,3 @@ import { PRODUCT_LAYER_MASK } from '../constant/VisibilityLayerMask'; | ||
this._mesh.receiveShadow = true; | ||
this._mesh.material = new MeshStandardMaterial(); | ||
this.add(this._mesh); | ||
@@ -45,4 +46,2 @@ | ||
public SetGeometry(geometry: COMGeometry): void { | ||
this.clear(); | ||
this._mesh.geometry = this.assembleGeometry(geometry); | ||
@@ -73,12 +72,28 @@ this._boundingBox.setFromObject(this._mesh); | ||
if (material.vertexColors !== undefined) { | ||
primitiveMaterial.vertexColors = material.vertexColors; | ||
} | ||
// apply color if supplied | ||
if (material.color !== undefined) primitiveMaterial.color = new Color(material.color); | ||
if (material.color !== undefined) { | ||
primitiveMaterial.color = new Color(material.color); | ||
} | ||
// apply albedo map if supplied | ||
if (material.map !== undefined) primitiveMaterial.map = material.map; | ||
if (material.map !== undefined) { | ||
primitiveMaterial.map = material.map; | ||
} | ||
// apply normal map | ||
if (material.normalMap !== undefined) { | ||
primitiveMaterial.normalMap = material.normalMap; | ||
} | ||
// set roughness value | ||
// if supplied, apply roughness map | ||
// if we applied a roughness map, set roughness to 1.0 | ||
if (material.roughness !== undefined) primitiveMaterial.roughness = material.roughness; | ||
if (material.roughness !== undefined) { | ||
primitiveMaterial.roughness = material.roughness; | ||
} | ||
if (material.roughnessMap !== undefined) { | ||
@@ -95,3 +110,6 @@ primitiveMaterial.roughnessMap = material.roughnessMap; | ||
// if we applied a metalness map, set metalness to 1.0 | ||
if (material.metalness !== undefined) primitiveMaterial.metalness = material.metalness; | ||
if (material.metalness !== undefined) { | ||
primitiveMaterial.metalness = material.metalness; | ||
} | ||
if (material.metalnessMap !== undefined) { | ||
@@ -101,3 +119,3 @@ primitiveMaterial.metalnessMap = material.metalnessMap; | ||
if (primitiveMaterial.metalnessMap) { | ||
primitiveMaterial.metalness = 1.0; | ||
primitiveMaterial.metalness = 0.0; | ||
} | ||
@@ -187,27 +205,16 @@ } | ||
private createCylinderGeometry(geometry: COMGeometry): BufferGeometry { | ||
return new CylinderGeometry(geometry.width * 2, geometry.width * 2, geometry.height, 64); | ||
const geo = new CylinderGeometry(geometry.width / 2, geometry.width / 2, geometry.height, 64); | ||
geo.translate(0, geometry.height / 2, 0); | ||
return geo; | ||
} | ||
private createSphereGeometry(geometry: COMGeometry): BufferGeometry { | ||
return new SphereGeometry(geometry.width * 2, 64); | ||
const geo = new SphereGeometry(geometry.width / 2, 256, 256); | ||
return geo; | ||
} | ||
private createPyramidGeometry(geometry: COMGeometry): BufferGeometry { | ||
const geo = new BufferGeometry(); | ||
const { width, height, depth } = geometry; | ||
geo.setAttribute('position', new Float32BufferAttribute([ | ||
width / 2, 0, depth / 2, // right back | ||
width / 2, 0, -depth / 2, // right front | ||
-width / 2, 0, -depth / 2, // left front | ||
-width / 2, 0, depth / 2, // left back | ||
0, height, 0, // top | ||
], 3)); | ||
geo.setIndex(new Uint32BufferAttribute([ | ||
1, 0, 4, | ||
2, 1, 4, | ||
3, 2, 4, | ||
3, 0, 4, | ||
0, 1, 2, | ||
0, 2, 3, | ||
], 1)); | ||
const geo = new ConeGeometry(geometry.width / 2, geometry.height, 4, 1, true); | ||
geo.rotateY(Math.PI / 4); | ||
geo.translate(0, geometry.height / 2, 0); | ||
return geo; | ||
@@ -217,16 +224,24 @@ } | ||
private createBoxGeometry(geometry: COMGeometry): BufferGeometry { | ||
return new BoxGeometry(geometry.width, geometry.height, geometry.depth); | ||
const geo = new BoxGeometry(geometry.width, geometry.height, geometry.depth); | ||
geo.translate(0, geometry.height / 2, 0); | ||
return geo; | ||
} | ||
private createConeGeometry(geometry: COMGeometry): BufferGeometry { | ||
return new CylinderGeometry(0, geometry.width * 2, geometry.height, 64); | ||
const geo = new ConeGeometry(geometry.width / 2, geometry.height, 256); | ||
geo.translate(0, geometry.height / 2, 0); | ||
return geo; | ||
} | ||
private createWallGeometry(geometry: COMGeometry): BufferGeometry { | ||
return new BoxGeometry(geometry.width, geometry.height, geometry.depth, 16); | ||
const geo = new BoxGeometry(geometry.width, geometry.height, geometry.depth || 0.05, 16); | ||
geo.translate(0, geometry.height / 2, 0); | ||
return geo; | ||
} | ||
private createPlaneGeometry(geometry: COMGeometry): BufferGeometry { | ||
return new BoxGeometry(geometry.width, geometry.height, geometry.depth); | ||
const geo = new BoxGeometry(geometry.width, geometry.height, geometry.depth); | ||
geo.translate(0, geometry.height / 2, 0); | ||
return geo; | ||
} | ||
} |
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
922798
14487