@shopware-ag/dive
Advanced tools
Comparing version 1.7.0 to 1.8.0
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Mesh, ColorRepresentation, Object3D, Intersection, Vector2, Raycaster, Vector3 } from 'three'; | ||
import { OrbitControls } from 'three/examples/jsm/Addons.js'; | ||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'; | ||
import { Tween } from '@tweenjs/tween.js'; | ||
@@ -13,2 +13,3 @@ import { TransformControls } from 'three/examples/jsm/Addons'; | ||
toneMapping: ToneMapping; | ||
canvas?: HTMLCanvasElement; | ||
}; | ||
@@ -28,3 +29,3 @@ /** | ||
private postRenderCallbacks; | ||
constructor(rendererSettings?: DIVERendererSettings); | ||
constructor(rendererSettings?: Partial<DIVERendererSettings>); | ||
Dispose(): void; | ||
@@ -88,3 +89,3 @@ StartRenderer(scene: Scene, cam: Camera): void; | ||
onSetCameraLayer: (mask: number) => void; | ||
constructor(settings?: DIVEPerspectiveCameraSettings); | ||
constructor(settings?: Partial<DIVEPerspectiveCameraSettings>); | ||
OnResize(width: number, height: number): void; | ||
@@ -129,3 +130,3 @@ SetCameraLayer(layer: 'LIVE' | 'EDITOR'): void; | ||
private _removePreRenderCallback; | ||
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings?: DIVEOrbitControlsSettings); | ||
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings?: Partial<DIVEOrbitControlsSettings>); | ||
Dispose(): void; | ||
@@ -715,5 +716,5 @@ ComputeEncompassingView(bb: Box3): { | ||
displayAxes: boolean; | ||
renderer: DIVERendererSettings; | ||
perspectiveCamera: DIVEPerspectiveCameraSettings; | ||
orbitControls: DIVEOrbitControlsSettings; | ||
renderer: Partial<DIVERendererSettings>; | ||
perspectiveCamera: Partial<DIVEPerspectiveCameraSettings>; | ||
orbitControls: Partial<DIVEOrbitControlsSettings>; | ||
}; | ||
@@ -720,0 +721,0 @@ declare const DIVEDefaultSettings: DIVESettings; |
{ | ||
"name": "@shopware-ag/dive", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "Shopware Spatial Framework", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -11,3 +11,3 @@ | ||
<a href="#badge"> | ||
<img alt="dive: licenst" src="https://img.shields.io/npm/l/%40shopware-ag%2Fdive"> | ||
<img alt="dive: license" src="https://img.shields.io/npm/l/%40shopware-ag%2Fdive"> | ||
</a> | ||
@@ -14,0 +14,0 @@ <a href="#badge"> |
@@ -186,2 +186,4 @@ import DIVE, { DIVESettings } from '../dive.ts'; | ||
console.log = jest.fn(); | ||
describe('dive/DIVE', () => { | ||
@@ -197,3 +199,2 @@ it('should QuickView', () => { | ||
expect((window as any).DIVE.PrintScene).toBeDefined(); | ||
console.log = jest.fn(); | ||
expect(() => (window as any).DIVE.PrintScene()).not.toThrow(); | ||
@@ -200,0 +201,0 @@ }); |
@@ -8,10 +8,19 @@ import DIVEPerspectiveCamera, { DIVEPerspectiveCameraDefaultSettings } from '../PerspectiveCamera'; | ||
jest.clearAllMocks(); | ||
cam = new DIVEPerspectiveCamera(DIVEPerspectiveCameraDefaultSettings); | ||
cam = new DIVEPerspectiveCamera(); | ||
}); | ||
it('should instantiate', () => { | ||
cam = new DIVEPerspectiveCamera(); | ||
cam = new DIVEPerspectiveCamera({}); | ||
expect(cam).toBeDefined(); | ||
}); | ||
it('should instantiate with settings', () => { | ||
cam = new DIVEPerspectiveCamera({ | ||
fov: 45, | ||
near: 0.1, | ||
far: 100, | ||
}); | ||
expect(cam).toBeDefined(); | ||
}); | ||
it('should resize', () => { | ||
@@ -18,0 +27,0 @@ const spy = jest.spyOn(cam, 'updateProjectionMatrix'); |
@@ -28,4 +28,9 @@ import { PerspectiveCamera } from "three"; | ||
constructor(settings: DIVEPerspectiveCameraSettings = DIVEPerspectiveCameraDefaultSettings) { | ||
super(settings.fov, 1, settings.near, settings.far); | ||
constructor(settings: Partial<DIVEPerspectiveCameraSettings> = DIVEPerspectiveCameraDefaultSettings) { | ||
super( | ||
settings.fov || DIVEPerspectiveCameraDefaultSettings.fov, | ||
1, | ||
settings.near || DIVEPerspectiveCameraDefaultSettings.near, | ||
settings.far || DIVEPerspectiveCameraDefaultSettings.far | ||
); | ||
@@ -32,0 +37,0 @@ this.layers.mask = DIVEPerspectiveCamera.EDITOR_VIEW_LAYER_MASK; |
@@ -15,3 +15,3 @@ import DIVEOrbitControls from '../OrbitControls'; | ||
jest.mock('three/examples/jsm/Addons.js', () => { | ||
jest.mock('three/examples/jsm/controls/OrbitControls', () => { | ||
return { | ||
@@ -46,5 +46,2 @@ OrbitControls: jest.fn(function () { | ||
}; | ||
this.target = { | ||
set: jest.fn(), | ||
}; | ||
this.update = jest.fn(); | ||
@@ -55,2 +52,4 @@ this.dispose = jest.fn(); | ||
clone: jest.fn(), | ||
set: jest.fn(), | ||
copy: jest.fn(), | ||
}; | ||
@@ -128,2 +127,5 @@ return this; | ||
}), | ||
set: jest.fn(() => { | ||
return mockCamera.position; | ||
}), | ||
}, | ||
@@ -155,6 +157,14 @@ lookAt: jest.fn(), | ||
it('should instantiate', () => { | ||
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem); | ||
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem, {}); | ||
expect(controller).toBeDefined(); | ||
}); | ||
it('should instantiate with settings', () => { | ||
const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem, { | ||
enableDamping: false, | ||
dampingFactor: 0.5, | ||
}); | ||
expect(controller).toBeDefined(); | ||
}); | ||
it('should dispose', () => { | ||
@@ -161,0 +171,0 @@ const controller = new DIVEOrbitControls(mockCamera, mockRenderer, mockAnimSystem); |
@@ -1,2 +0,2 @@ | ||
import { OrbitControls } from "three/examples/jsm/Addons.js"; | ||
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"; | ||
import DIVEPerspectiveCamera from "../camera/PerspectiveCamera.ts"; | ||
@@ -42,3 +42,3 @@ import { DIVERenderer } from "../renderer/Renderer.ts"; | ||
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings: DIVEOrbitControlsSettings = DIVEOrbitControlsDefaultSettings) { | ||
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings: Partial<DIVEOrbitControlsSettings> = DIVEOrbitControlsDefaultSettings) { | ||
super(camera, renderer.domElement); | ||
@@ -60,4 +60,9 @@ | ||
this.enableDamping = settings.enableDamping; | ||
this.dampingFactor = settings.dampingFactor; | ||
this.enableDamping = settings.enableDamping || DIVEOrbitControlsDefaultSettings.enableDamping; | ||
this.dampingFactor = settings.dampingFactor || DIVEOrbitControlsDefaultSettings.dampingFactor; | ||
// initialize camera transformation | ||
this.object.position.set(0, 2, 2); | ||
this.target.copy({ x: 0, y: 0.5, z: 0 }); | ||
this.update(); | ||
} | ||
@@ -64,0 +69,0 @@ |
@@ -20,5 +20,5 @@ import { DIVERenderer, DIVERendererDefaultSettings, DIVERendererSettings } from "./renderer/Renderer.ts"; | ||
displayAxes: boolean; | ||
renderer: DIVERendererSettings; | ||
perspectiveCamera: DIVEPerspectiveCameraSettings; | ||
orbitControls: DIVEOrbitControlsSettings; | ||
renderer: Partial<DIVERendererSettings>; | ||
perspectiveCamera: Partial<DIVEPerspectiveCameraSettings>; | ||
orbitControls: Partial<DIVEOrbitControlsSettings>; | ||
} | ||
@@ -163,5 +163,5 @@ | ||
if (settingsDelta.perspectiveCamera) { | ||
this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov; | ||
this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near; | ||
this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far; | ||
if (settingsDelta.perspectiveCamera.fov !== undefined) this.perspectiveCamera.fov = settingsDelta.perspectiveCamera.fov; | ||
if (settingsDelta.perspectiveCamera.near !== undefined) this.perspectiveCamera.near = settingsDelta.perspectiveCamera.near; | ||
if (settingsDelta.perspectiveCamera.far !== undefined) this.perspectiveCamera.far = settingsDelta.perspectiveCamera.far; | ||
this.perspectiveCamera.OnResize(this.renderer.domElement.width, this.renderer.domElement.height); | ||
@@ -171,4 +171,4 @@ } | ||
if (settingsDelta.orbitControls) { | ||
this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping; | ||
this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor; | ||
if (settingsDelta.orbitControls.enableDamping !== undefined) this.orbitControls.enableDamping = settingsDelta.orbitControls.enableDamping; | ||
if (settingsDelta.orbitControls.dampingFactor !== undefined) this.orbitControls.dampingFactor = settingsDelta.orbitControls.dampingFactor; | ||
} | ||
@@ -235,2 +235,4 @@ | ||
} | ||
console.log('DIVE initialized'); | ||
} | ||
@@ -237,0 +239,0 @@ |
@@ -51,5 +51,16 @@ import type DIVEPerspectiveCamera from '../../camera/PerspectiveCamera'; | ||
it('should instantiate', () => { | ||
renderer = new DIVERenderer({}); | ||
expect(renderer).toBeDefined(); | ||
}); | ||
it('should instantiate', () => { | ||
renderer = new DIVERenderer({ | ||
alpha: true, | ||
shadowMapEnabled: true, | ||
shadowMapType: 1, | ||
toneMapping: 1, | ||
antialias: true, | ||
}); | ||
}); | ||
it('should instantiate with settings parameter', () => { | ||
@@ -56,0 +67,0 @@ renderer = new DIVERenderer(DIVERendererDefaultSettings); |
@@ -10,2 +10,3 @@ import { Camera, MathUtils, NoToneMapping, PCFSoftShadowMap, Scene, ShadowMapType, ToneMapping, WebGLRenderer } from "three"; | ||
toneMapping: ToneMapping; | ||
canvas?: HTMLCanvasElement; | ||
} | ||
@@ -20,2 +21,3 @@ | ||
toneMapping: NoToneMapping, | ||
canvas: undefined, | ||
} | ||
@@ -41,14 +43,15 @@ | ||
constructor(rendererSettings: DIVERendererSettings = DIVERendererDefaultSettings) { | ||
constructor(rendererSettings: Partial<DIVERendererSettings> = DIVERendererDefaultSettings) { | ||
super({ | ||
antialias: rendererSettings.antialias, | ||
alpha: rendererSettings.alpha, | ||
preserveDrawingBuffer: true | ||
antialias: rendererSettings.antialias || DIVERendererDefaultSettings.antialias, | ||
alpha: rendererSettings.alpha || DIVERendererDefaultSettings.alpha, | ||
preserveDrawingBuffer: true, | ||
canvas: rendererSettings.canvas, | ||
}); | ||
this.setPixelRatio(window.devicePixelRatio); | ||
this.shadowMap.enabled = rendererSettings.shadowMapEnabled; | ||
this.shadowMap.type = rendererSettings.shadowMapType; | ||
this.shadowMap.enabled = rendererSettings.shadowMapEnabled || DIVERendererDefaultSettings.shadowMapEnabled; | ||
this.shadowMap.type = rendererSettings.shadowMapType || DIVERendererDefaultSettings.shadowMapType; | ||
this.toneMapping = rendererSettings.toneMapping; | ||
this.toneMapping = rendererSettings.toneMapping || DIVERendererDefaultSettings.toneMapping; | ||
@@ -55,0 +58,0 @@ this.debug.checkShaderErrors = false; |
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
805478
12792