@shopware-ag/dive 1.0.18 → 1.1.1
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/dive.cjs +1508 -0
- package/build/dive.cjs.map +1 -0
- package/build/dive.d.cts +559 -0
- package/build/dive.d.ts +559 -0
- package/build/dive.js +1473 -0
- package/build/dive.js.map +1 -0
- package/package.json +1 -1
- package/src/com/types.ts +1 -0
- package/src/light/AmbientLight.ts +14 -7
- package/src/light/PointLight.ts +24 -16
- package/src/light/SceneLight.ts +26 -25
- package/src/light/__test__/AmbientLight.test.ts +12 -4
- package/src/light/__test__/PointLight.test.ts +20 -7
- package/src/light/__test__/SceneLight.test.ts +10 -4
- package/src/scene/root/lightroot/LightRoot.ts +1 -0
- package/src/scene/root/lightroot/__test__/LightRoot.test.ts +1 -1
- package/src/scene/root/modelroot/ModelRoot.ts +1 -0
- package/src/scene/root/modelroot/__test__/ModelRoot.test.ts +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import DIVESceneLight from '../SceneLight';
|
|
2
2
|
import DIVECommunication from '../../com/Communication';
|
|
3
|
-
import { Color } from 'three';
|
|
3
|
+
import { Color, HemisphereLight as THREEHemisphereLight, DirectionalLight as THREEDirectionalLight, Object3D } from 'three';
|
|
4
4
|
|
|
5
5
|
jest.mock('../../com/Communication.ts', () => {
|
|
6
6
|
return {
|
|
@@ -57,10 +57,14 @@ jest.mock('three', () => {
|
|
|
57
57
|
return this;
|
|
58
58
|
}),
|
|
59
59
|
Object3D: jest.fn(function () {
|
|
60
|
-
this.
|
|
60
|
+
this.children = [];
|
|
61
|
+
this.add = (obj: Object3D) => {
|
|
62
|
+
this.children.push(obj);
|
|
63
|
+
};
|
|
61
64
|
return this;
|
|
62
65
|
}),
|
|
63
66
|
HemisphereLight: jest.fn(function () {
|
|
67
|
+
this.visible = true;
|
|
64
68
|
this.layers = {
|
|
65
69
|
mask: 0,
|
|
66
70
|
};
|
|
@@ -71,6 +75,7 @@ jest.mock('three', () => {
|
|
|
71
75
|
return this;
|
|
72
76
|
}),
|
|
73
77
|
DirectionalLight: jest.fn(function () {
|
|
78
|
+
this.visible = true;
|
|
74
79
|
this.layers = {
|
|
75
80
|
mask: 0,
|
|
76
81
|
};
|
|
@@ -100,7 +105,7 @@ describe('dive/light/DIVESceneLight', () => {
|
|
|
100
105
|
it('should instantiate', () => {
|
|
101
106
|
const testLight = new DIVESceneLight();
|
|
102
107
|
expect(testLight).toBeDefined();
|
|
103
|
-
expect(
|
|
108
|
+
expect(testLight.children).toHaveLength(2);
|
|
104
109
|
});
|
|
105
110
|
|
|
106
111
|
it('should set intensity', () => {
|
|
@@ -117,6 +122,7 @@ describe('dive/light/DIVESceneLight', () => {
|
|
|
117
122
|
it('should set enabled', () => {
|
|
118
123
|
const testLight = new DIVESceneLight();
|
|
119
124
|
testLight.SetEnabled(false);
|
|
120
|
-
expect(testLight.visible).toBe(false);
|
|
125
|
+
expect(testLight.children[0].visible).toBe(false);
|
|
126
|
+
expect(testLight.children[1].visible).toBe(false);
|
|
121
127
|
});
|
|
122
128
|
});
|
|
@@ -61,6 +61,7 @@ export default class DIVELightRoot extends Object3D {
|
|
|
61
61
|
if (light.intensity !== undefined && light.intensity !== null) (sceneObject as (DIVEAmbientLight | DIVEPointLight)).SetIntensity(light.intensity);
|
|
62
62
|
if (light.enabled !== undefined && light.enabled !== null) (sceneObject as (DIVEAmbientLight | DIVEPointLight)).SetEnabled(light.enabled);
|
|
63
63
|
if (light.color !== undefined && light.color !== null) (sceneObject as (DIVEAmbientLight | DIVEPointLight)).SetColor(new Color(light.color));
|
|
64
|
+
if (light.visible !== undefined && light.visible !== null) (sceneObject as (DIVEAmbientLight | DIVEPointLight)).visible = light.visible;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
public DeleteLight(light: Partial<COMLight>): void {
|
|
@@ -74,7 +74,7 @@ describe('dive/scene/root/lightroot/DIVELightRoot', () => {
|
|
|
74
74
|
|
|
75
75
|
it('should update basic scene light', () => {
|
|
76
76
|
const lightRoot = new DIVELightRoot();
|
|
77
|
-
lightRoot.UpdateLight({ id: 'test_id', type: 'scene', name: 'test', position: undefined, enabled: true });
|
|
77
|
+
lightRoot.UpdateLight({ id: 'test_id', type: 'scene', name: 'test', position: undefined, enabled: true, visible: false });
|
|
78
78
|
expect(lightRoot.children).toHaveLength(1);
|
|
79
79
|
expect(lightRoot.children[0].userData.id).toBe('test_id');
|
|
80
80
|
});
|
|
@@ -50,6 +50,7 @@ export default class DIVEModelRoot extends Object3D {
|
|
|
50
50
|
if (object.position !== undefined) (sceneObject as Model).SetPosition(object.position);
|
|
51
51
|
if (object.rotation !== undefined) (sceneObject as Model).SetRotation(object.rotation);
|
|
52
52
|
if (object.scale !== undefined) (sceneObject as Model).SetScale(object.scale);
|
|
53
|
+
if (object.visible !== undefined) (sceneObject as Model).visible = object.visible;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
public DeleteModel(object: Partial<COMModel>): void {
|
|
@@ -77,6 +77,7 @@ describe('dive/scene/root/modelroot/DIVEModelRoot', () => {
|
|
|
77
77
|
await expect(() => modelRoot.UpdateModel({
|
|
78
78
|
id: 'test_id',
|
|
79
79
|
uri: 'not a real uri',
|
|
80
|
+
visible: false,
|
|
80
81
|
})).not.toThrow();
|
|
81
82
|
expect(mock_LoadGLTF).toHaveBeenCalledTimes(1);
|
|
82
83
|
expect(mock_SetModel).toHaveBeenCalledTimes(1);
|