@lukekaalim/act-three 5.12.3 → 5.12.4
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/components/scene.js +21 -0
- package/package.json +1 -1
- package/props.js +13 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
/*::
|
|
3
|
+
import type { SceneProps } from "../components";
|
|
4
|
+
import type { Scene, Texture } from "three";
|
|
5
|
+
*/
|
|
6
|
+
import { Color } from "three";
|
|
7
|
+
|
|
8
|
+
/*::
|
|
9
|
+
export type PropSetters<T> = {
|
|
10
|
+
[string]: (object: T, nextProp: any, prevProp: any) => void,
|
|
11
|
+
}
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export const scenePropSetters/*: PropSetters<Scene>*/ = {
|
|
15
|
+
'background': (scene/*: Scene*/, prop/*: null | Color | Texture*/) => {
|
|
16
|
+
if (scene.background instanceof Color && prop instanceof Color)
|
|
17
|
+
scene.background.copy(prop)
|
|
18
|
+
else
|
|
19
|
+
scene.background = prop;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
CHANGED
package/props.js
CHANGED
|
@@ -22,10 +22,12 @@ import {
|
|
|
22
22
|
Object3D,
|
|
23
23
|
OrthographicCamera,
|
|
24
24
|
Quaternion,
|
|
25
|
+
Scene,
|
|
25
26
|
Vector2,
|
|
26
27
|
Vector3,
|
|
27
28
|
} from "three";
|
|
28
29
|
import { setRef } from "@lukekaalim/act-renderer-core";
|
|
30
|
+
import { scenePropSetters } from './components/scene';
|
|
29
31
|
|
|
30
32
|
export const setTransformProp = (target/*: mixed*/, diff/*: PropDiff*/)/*: boolean*/ => {
|
|
31
33
|
if (target instanceof Vector2 && diff.next instanceof Vector2) {
|
|
@@ -131,7 +133,7 @@ export const setObjectProps2 = (
|
|
|
131
133
|
}
|
|
132
134
|
if (setInstanceProp((object/*: any*/), key, propDiff))
|
|
133
135
|
continue;
|
|
134
|
-
|
|
136
|
+
|
|
135
137
|
if (setMeshProp((object/*: any*/), key, propDiff)) {
|
|
136
138
|
continue;
|
|
137
139
|
}
|
|
@@ -139,10 +141,20 @@ export const setObjectProps2 = (
|
|
|
139
141
|
continue;
|
|
140
142
|
if (setValueProp((object/*: any*/), key, propDiff))
|
|
141
143
|
continue;
|
|
144
|
+
if (object instanceof Scene) {
|
|
145
|
+
const setter = scenePropSetters[propDiff.key];
|
|
146
|
+
if (setter) {
|
|
147
|
+
setter(object, propDiff.next, propDiff.prev);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
142
153
|
|
|
143
154
|
console.warn(`Unhandled prop ${key}`, propDiff.next, object);
|
|
144
155
|
}
|
|
145
156
|
|
|
146
157
|
if (object instanceof OrthographicCamera)
|
|
147
158
|
object.updateProjectionMatrix();
|
|
159
|
+
|
|
148
160
|
}
|