react-three-game 0.0.94 → 0.0.95
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/dist/tools/prefabeditor/PrefabRoot.js +57 -18
- package/dist/tools/prefabeditor/components/MaterialComponent.d.ts +5 -2
- package/dist/tools/prefabeditor/components/MaterialComponent.js +40 -24
- package/dist/tools/prefabeditor/components/SpriteComponent.d.ts +8 -0
- package/dist/tools/prefabeditor/components/SpriteComponent.js +27 -0
- package/dist/tools/prefabeditor/components/index.js +22 -14
- package/package.json +1 -1
|
@@ -240,11 +240,12 @@ function getClickEventName(component) {
|
|
|
240
240
|
return typeof eventName === 'string' && eventName.trim() ? eventName.trim() : null;
|
|
241
241
|
}
|
|
242
242
|
function analyzeNodeComponents(node) {
|
|
243
|
-
var _a, _b, _c;
|
|
243
|
+
var _a, _b, _c, _d;
|
|
244
244
|
let bufferGeometry;
|
|
245
245
|
let geometry;
|
|
246
246
|
let material;
|
|
247
247
|
let model;
|
|
248
|
+
let sprite;
|
|
248
249
|
const composition = [];
|
|
249
250
|
for (const [key, component] of Object.entries((_a = node.components) !== null && _a !== void 0 ? _a : {})) {
|
|
250
251
|
if (!(component === null || component === void 0 ? void 0 : component.type))
|
|
@@ -264,6 +265,9 @@ function analyzeNodeComponents(node) {
|
|
|
264
265
|
case "Model":
|
|
265
266
|
model = component;
|
|
266
267
|
break;
|
|
268
|
+
case "Sprite":
|
|
269
|
+
sprite = component;
|
|
270
|
+
break;
|
|
267
271
|
default: {
|
|
268
272
|
const def = getComponentDef(component.type);
|
|
269
273
|
if (!(def === null || def === void 0 ? void 0 : def.View))
|
|
@@ -281,7 +285,8 @@ function analyzeNodeComponents(node) {
|
|
|
281
285
|
geometry: bufferGeometry !== null && bufferGeometry !== void 0 ? bufferGeometry : geometry,
|
|
282
286
|
material,
|
|
283
287
|
model,
|
|
284
|
-
|
|
288
|
+
sprite,
|
|
289
|
+
clickEventName: (_d = (_c = (_b = getClickEventName(bufferGeometry)) !== null && _b !== void 0 ? _b : getClickEventName(geometry)) !== null && _c !== void 0 ? _c : getClickEventName(model)) !== null && _d !== void 0 ? _d : getClickEventName(sprite),
|
|
285
290
|
composition,
|
|
286
291
|
};
|
|
287
292
|
}
|
|
@@ -471,24 +476,58 @@ function getNodeTransformProps(node) {
|
|
|
471
476
|
function renderNodeContent(analyzedComponents, loadedModels, primaryClickHandlers, childNodes) {
|
|
472
477
|
var _a, _b, _c, _d;
|
|
473
478
|
const geometry = analyzedComponents.geometry;
|
|
474
|
-
const
|
|
475
|
-
const
|
|
476
|
-
const
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
479
|
+
const model = analyzedComponents.model;
|
|
480
|
+
const material = analyzedComponents.material;
|
|
481
|
+
const sprite = analyzedComponents.sprite;
|
|
482
|
+
const shapeKind = (sprite === null || sprite === void 0 ? void 0 : sprite.type) ? 'sprite' : (geometry === null || geometry === void 0 ? void 0 : geometry.type) ? 'mesh' : (model === null || model === void 0 ? void 0 : model.type) ? 'model' : 'none';
|
|
483
|
+
let materialContent = null;
|
|
484
|
+
switch (shapeKind) {
|
|
485
|
+
case 'sprite': {
|
|
486
|
+
const materialDef = (material === null || material === void 0 ? void 0 : material.type) ? getComponentDef(material.type) : undefined;
|
|
487
|
+
if ((material === null || material === void 0 ? void 0 : material.properties) && (materialDef === null || materialDef === void 0 ? void 0 : materialDef.View)) {
|
|
488
|
+
const materialIsSprite = material.properties.materialType === 'sprite';
|
|
489
|
+
materialContent = (_jsx(materialDef.View, { properties: Object.assign(Object.assign({}, material.properties), { materialType: 'sprite', transparent: materialIsSprite ? material.properties.transparent : true, depthTest: materialIsSprite ? material.properties.depthTest : false, depthWrite: materialIsSprite ? material.properties.depthWrite : false }) }, "material"));
|
|
490
|
+
}
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
case 'mesh': {
|
|
494
|
+
const materialDef = (material === null || material === void 0 ? void 0 : material.type) ? getComponentDef(material.type) : undefined;
|
|
495
|
+
if ((material === null || material === void 0 ? void 0 : material.properties) && (materialDef === null || materialDef === void 0 ? void 0 : materialDef.View)) {
|
|
496
|
+
materialContent = _jsx(materialDef.View, { properties: material.properties }, "material");
|
|
497
|
+
}
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
484
500
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
501
|
+
let primaryContent = null;
|
|
502
|
+
let contentChildren = childNodes;
|
|
503
|
+
switch (shapeKind) {
|
|
504
|
+
case 'sprite': {
|
|
505
|
+
primaryContent = (_jsxs("sprite", Object.assign({ center: (_b = (_a = sprite === null || sprite === void 0 ? void 0 : sprite.properties) === null || _a === void 0 ? void 0 : _a.center) !== null && _b !== void 0 ? _b : [0.5, 0.5] }, primaryClickHandlers, { children: [materialContent, childNodes] })));
|
|
506
|
+
contentChildren = null;
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
case 'mesh': {
|
|
510
|
+
const geometryDef = (geometry === null || geometry === void 0 ? void 0 : geometry.type) ? getComponentDef(geometry.type) : undefined;
|
|
511
|
+
if (!(geometry === null || geometry === void 0 ? void 0 : geometry.properties) || !(geometryDef === null || geometryDef === void 0 ? void 0 : geometryDef.View))
|
|
512
|
+
break;
|
|
513
|
+
const GeometryView = geometryDef.View;
|
|
514
|
+
const geometryProperties = (_c = geometry.properties) !== null && _c !== void 0 ? _c : {};
|
|
515
|
+
const visible = geometryProperties.visible !== false;
|
|
516
|
+
primaryContent = (_jsxs("mesh", Object.assign({ visible: visible, castShadow: visible && geometryProperties.castShadow !== false, receiveShadow: visible && geometryProperties.receiveShadow !== false }, primaryClickHandlers, { children: [_jsx(GeometryView, { properties: geometry.properties }), materialContent] })));
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
case 'model': {
|
|
520
|
+
if (!(model === null || model === void 0 ? void 0 : model.type) || ((_d = model.properties) === null || _d === void 0 ? void 0 : _d.instanced) || !isNodeReady(model, loadedModels))
|
|
521
|
+
break;
|
|
522
|
+
const modelDef = getComponentDef(model.type);
|
|
523
|
+
if (!(modelDef === null || modelDef === void 0 ? void 0 : modelDef.View))
|
|
524
|
+
break;
|
|
525
|
+
const modelContent = _jsx(modelDef.View, { properties: model.properties });
|
|
526
|
+
primaryContent = primaryClickHandlers ? _jsx("group", Object.assign({}, primaryClickHandlers, { children: modelContent })) : modelContent;
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
490
529
|
}
|
|
491
|
-
let content = _jsxs(_Fragment, { children: [primaryContent,
|
|
530
|
+
let content = _jsxs(_Fragment, { children: [primaryContent, contentChildren] });
|
|
492
531
|
for (const { key, View, properties } of analyzedComponents.composition) {
|
|
493
532
|
content = (_jsx(View, { properties: properties, children: content }, key));
|
|
494
533
|
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { ThreeElement } from '@react-three/fiber';
|
|
3
3
|
import { Component } from './ComponentRegistry';
|
|
4
|
-
import { MeshBasicNodeMaterial, MeshStandardNodeMaterial } from 'three/webgpu';
|
|
4
|
+
import { MeshBasicNodeMaterial, MeshStandardNodeMaterial, SpriteNodeMaterial } from 'three/webgpu';
|
|
5
5
|
import { MeshBasicMaterialProperties, MeshStandardMaterialProperties } from 'three';
|
|
6
6
|
declare module '@react-three/fiber' {
|
|
7
7
|
interface ThreeElements {
|
|
8
8
|
meshBasicNodeMaterial: ThreeElement<typeof MeshBasicNodeMaterial>;
|
|
9
9
|
meshStandardNodeMaterial: ThreeElement<typeof MeshStandardNodeMaterial>;
|
|
10
|
+
spriteNodeMaterial: ThreeElement<typeof SpriteNodeMaterial>;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
export interface MaterialProps extends Omit<MeshStandardMaterialProperties & MeshBasicMaterialProperties, 'args' | 'normalScale'> {
|
|
13
|
-
materialType?: 'standard' | 'basic';
|
|
14
|
+
materialType?: 'standard' | 'basic' | 'sprite';
|
|
14
15
|
transmission?: number;
|
|
15
16
|
thickness?: number;
|
|
16
17
|
ior?: number;
|
|
18
|
+
rotation?: number;
|
|
19
|
+
sizeAttenuation?: boolean;
|
|
17
20
|
texture?: string;
|
|
18
21
|
offset?: [number, number];
|
|
19
22
|
repeat?: boolean;
|
|
@@ -15,7 +15,7 @@ import { extend } from '@react-three/fiber';
|
|
|
15
15
|
import { useFrame } from '@react-three/fiber';
|
|
16
16
|
import { FieldRenderer, Label, NumberInput } from './Input';
|
|
17
17
|
import { useAssetRuntime } from '../assetRuntime';
|
|
18
|
-
import { MeshBasicNodeMaterial, MeshStandardNodeMaterial } from 'three/webgpu';
|
|
18
|
+
import { MeshBasicNodeMaterial, MeshStandardNodeMaterial, SpriteNodeMaterial } from 'three/webgpu';
|
|
19
19
|
import { TexturePicker } from '../../assetviewer/page';
|
|
20
20
|
import { RepeatWrapping, ClampToEdgeWrapping, SRGBColorSpace, LinearSRGBColorSpace, NearestFilter, LinearFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapNearestFilter, LinearMipmapLinearFilter, FrontSide, BackSide, DoubleSide, } from 'three';
|
|
21
21
|
function Vector2Editor({ label, value, onChange, min, max, step, }) {
|
|
@@ -35,6 +35,7 @@ export function MaterialOverridesProvider({ overrides, children, }) {
|
|
|
35
35
|
extend({
|
|
36
36
|
MeshBasicNodeMaterial,
|
|
37
37
|
MeshStandardNodeMaterial,
|
|
38
|
+
SpriteNodeMaterial,
|
|
38
39
|
});
|
|
39
40
|
function MaterialComponentEditor({ component, onUpdate, basePath = "" }) {
|
|
40
41
|
var _a;
|
|
@@ -43,6 +44,7 @@ function MaterialComponentEditor({ component, onUpdate, basePath = "" }) {
|
|
|
43
44
|
const hasRepeat = component.properties.repeat;
|
|
44
45
|
const animateOffset = component.properties.animateOffset;
|
|
45
46
|
const isStandardMaterial = materialType === 'standard';
|
|
47
|
+
const isSpriteMaterial = materialType === 'sprite';
|
|
46
48
|
const fields = [
|
|
47
49
|
{
|
|
48
50
|
name: 'materialType',
|
|
@@ -51,13 +53,22 @@ function MaterialComponentEditor({ component, onUpdate, basePath = "" }) {
|
|
|
51
53
|
options: [
|
|
52
54
|
{ value: 'standard', label: 'Standard' },
|
|
53
55
|
{ value: 'basic', label: 'Basic' },
|
|
56
|
+
{ value: 'sprite', label: 'Sprite' },
|
|
54
57
|
],
|
|
55
58
|
},
|
|
56
59
|
{ name: 'color', type: 'color', label: 'Color' },
|
|
57
60
|
{ name: 'toneMapped', type: 'boolean', label: 'Tone Mapped' },
|
|
58
|
-
|
|
61
|
+
...(!isSpriteMaterial ? [
|
|
62
|
+
{ name: 'wireframe', type: 'boolean', label: 'Wireframe' },
|
|
63
|
+
] : []),
|
|
59
64
|
{ name: 'transparent', type: 'boolean', label: 'Transparent' },
|
|
60
65
|
{ name: 'opacity', type: 'number', label: 'Opacity', min: 0, max: 1, step: 0.01 },
|
|
66
|
+
...(isSpriteMaterial ? [
|
|
67
|
+
{ name: 'rotation', type: 'number', label: 'Rotation', step: 0.01 },
|
|
68
|
+
{ name: 'sizeAttenuation', type: 'boolean', label: 'Size Attenuation' },
|
|
69
|
+
{ name: 'depthTest', type: 'boolean', label: 'Depth Test' },
|
|
70
|
+
{ name: 'depthWrite', type: 'boolean', label: 'Depth Write' },
|
|
71
|
+
] : []),
|
|
61
72
|
...(isStandardMaterial ? [
|
|
62
73
|
{ name: 'metalness', type: 'number', label: 'Metalness', min: 0, max: 1, step: 0.01 },
|
|
63
74
|
{ name: 'roughness', type: 'number', label: 'Roughness', min: 0, max: 1, step: 0.01 },
|
|
@@ -65,16 +76,16 @@ function MaterialComponentEditor({ component, onUpdate, basePath = "" }) {
|
|
|
65
76
|
{ name: 'thickness', type: 'number', label: 'Thickness', min: 0, step: 0.1 },
|
|
66
77
|
{ name: 'ior', type: 'number', label: 'IOR (Index of Refraction)', min: 1, max: 2.333, step: 0.01 },
|
|
67
78
|
] : []),
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
...(!isSpriteMaterial ? [{
|
|
80
|
+
name: 'side',
|
|
81
|
+
type: 'select',
|
|
82
|
+
label: 'Side',
|
|
83
|
+
options: [
|
|
84
|
+
{ value: 'FrontSide', label: 'Front' },
|
|
85
|
+
{ value: 'BackSide', label: 'Back' },
|
|
86
|
+
{ value: 'DoubleSide', label: 'Double' },
|
|
87
|
+
],
|
|
88
|
+
}] : []),
|
|
78
89
|
{
|
|
79
90
|
name: 'texture',
|
|
80
91
|
type: 'custom',
|
|
@@ -103,13 +114,13 @@ function MaterialComponentEditor({ component, onUpdate, basePath = "" }) {
|
|
|
103
114
|
label: 'Speed (X, Y)',
|
|
104
115
|
render: ({ value, onChange }) => (_jsx(Vector2Editor, { label: "Speed", value: value, onChange: onChange, step: 0.01 })),
|
|
105
116
|
}] : []),
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
...(component.properties.normalMapTexture ? [{
|
|
117
|
+
...(!isSpriteMaterial ? [{
|
|
118
|
+
name: 'normalMapTexture',
|
|
119
|
+
type: 'custom',
|
|
120
|
+
label: 'Normal Map',
|
|
121
|
+
render: ({ value, onChange }) => (_jsx(TexturePicker, { value: value, onChange: onChange, basePath: basePath })),
|
|
122
|
+
}] : []),
|
|
123
|
+
...(!isSpriteMaterial && component.properties.normalMapTexture ? [{
|
|
113
124
|
name: 'normalScale',
|
|
114
125
|
type: 'custom',
|
|
115
126
|
label: 'Normal Scale (X, Y)',
|
|
@@ -144,7 +155,7 @@ function MaterialComponentEditor({ component, onUpdate, basePath = "" }) {
|
|
|
144
155
|
}
|
|
145
156
|
// View for Material component
|
|
146
157
|
function MaterialComponentView({ properties: rawProps }) {
|
|
147
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
158
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
148
159
|
const { getTexture } = useAssetRuntime();
|
|
149
160
|
const properties = rawProps;
|
|
150
161
|
const materialType = (_a = properties === null || properties === void 0 ? void 0 : properties.materialType) !== null && _a !== void 0 ? _a : 'standard';
|
|
@@ -163,7 +174,7 @@ function MaterialComponentView({ properties: rawProps }) {
|
|
|
163
174
|
const normalMapTexture = normalMapTextureName ? (_c = getTexture(normalMapTextureName)) !== null && _c !== void 0 ? _c : undefined : undefined;
|
|
164
175
|
const materialSource = properties !== null && properties !== void 0 ? properties : {};
|
|
165
176
|
// Destructure all material props and separate custom texture handling props
|
|
166
|
-
const { texture: _texture, offset: _offset, repeat: _repeat, repeatCount: _repeatCount, animateOffset: _animateOffset, offsetSpeed: _offsetSpeed, generateMipmaps: _generateMipmaps, minFilter: _minFilter, magFilter: _magFilter, map: _map, materialType: _materialType, normalMapTexture: _normalMapTexture, normalScale: _normalScale, normalMap: _normalMap, side: sideProp } = materialSource, materialProps = __rest(materialSource, ["texture", "offset", "repeat", "repeatCount", "animateOffset", "offsetSpeed", "generateMipmaps", "minFilter", "magFilter", "map", "materialType", "normalMapTexture", "normalScale", "normalMap", "side"]);
|
|
177
|
+
const { texture: _texture, offset: _offset, repeat: _repeat, repeatCount: _repeatCount, animateOffset: _animateOffset, offsetSpeed: _offsetSpeed, generateMipmaps: _generateMipmaps, minFilter: _minFilter, magFilter: _magFilter, map: _map, materialType: _materialType, normalMapTexture: _normalMapTexture, normalScale: _normalScale, normalMap: _normalMap, rotation, sizeAttenuation, side: sideProp } = materialSource, materialProps = __rest(materialSource, ["texture", "offset", "repeat", "repeatCount", "animateOffset", "offsetSpeed", "generateMipmaps", "minFilter", "magFilter", "map", "materialType", "normalMapTexture", "normalScale", "normalMap", "rotation", "sizeAttenuation", "side"]);
|
|
167
178
|
const sideMap = { FrontSide, BackSide, DoubleSide };
|
|
168
179
|
const resolvedSide = sideProp ? ((_d = sideMap[sideProp]) !== null && _d !== void 0 ? _d : FrontSide) : FrontSide;
|
|
169
180
|
const minFilterMap = {
|
|
@@ -220,14 +231,18 @@ function MaterialComponentView({ properties: rawProps }) {
|
|
|
220
231
|
return t;
|
|
221
232
|
}, [normalMapTexture]);
|
|
222
233
|
if (!properties) {
|
|
223
|
-
return _jsx("meshStandardNodeMaterial", { color: "red", wireframe: true });
|
|
234
|
+
return _jsx("meshStandardNodeMaterial", { attach: "material", color: "red", wireframe: true });
|
|
224
235
|
}
|
|
225
236
|
const overrides = useMaterialOverrides();
|
|
226
237
|
const sharedProps = Object.assign(Object.assign({ map: finalTexture, side: resolvedSide }, materialProps), overrides);
|
|
227
238
|
if (materialType === 'basic') {
|
|
228
|
-
return _jsx("meshBasicNodeMaterial", Object.assign({}, sharedProps));
|
|
239
|
+
return _jsx("meshBasicNodeMaterial", Object.assign({ attach: "material" }, sharedProps));
|
|
240
|
+
}
|
|
241
|
+
if (materialType === 'sprite') {
|
|
242
|
+
const spriteTransparent = properties.transparent !== false;
|
|
243
|
+
return (_jsx("spriteNodeMaterial", Object.assign({ attach: "material", map: finalTexture, color: (_j = properties.color) !== null && _j !== void 0 ? _j : '#ffffff', opacity: (_k = properties.opacity) !== null && _k !== void 0 ? _k : 1, transparent: spriteTransparent, alphaTest: (_l = properties.alphaTest) !== null && _l !== void 0 ? _l : 0, depthTest: (_m = properties.depthTest) !== null && _m !== void 0 ? _m : false, depthWrite: (_o = properties.depthWrite) !== null && _o !== void 0 ? _o : false, toneMapped: (_p = properties.toneMapped) !== null && _p !== void 0 ? _p : true }, overrides, { rotation: rotation !== null && rotation !== void 0 ? rotation : 0, sizeAttenuation: sizeAttenuation !== null && sizeAttenuation !== void 0 ? sizeAttenuation : true })));
|
|
229
244
|
}
|
|
230
|
-
return (_jsx("meshStandardNodeMaterial", Object.assign({}, sharedProps, { normalMap: finalNormalMap, normalScale: finalNormalMap ? [(
|
|
245
|
+
return (_jsx("meshStandardNodeMaterial", Object.assign({ attach: "material" }, sharedProps, { normalMap: finalNormalMap, normalScale: finalNormalMap ? [(_q = normalScaleProp === null || normalScaleProp === void 0 ? void 0 : normalScaleProp[0]) !== null && _q !== void 0 ? _q : 1, (_r = normalScaleProp === null || normalScaleProp === void 0 ? void 0 : normalScaleProp[1]) !== null && _r !== void 0 ? _r : 1] : undefined })));
|
|
231
246
|
}
|
|
232
247
|
const MaterialComponent = {
|
|
233
248
|
name: 'Material',
|
|
@@ -240,6 +255,7 @@ const MaterialComponent = {
|
|
|
240
255
|
wireframe: false,
|
|
241
256
|
transparent: false,
|
|
242
257
|
opacity: 1,
|
|
258
|
+
sizeAttenuation: true,
|
|
243
259
|
offset: [0, 0],
|
|
244
260
|
animateOffset: false,
|
|
245
261
|
offsetSpeed: [0, 0],
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { BooleanField, FieldRenderer, NumberInput, StringField } from './Input';
|
|
3
|
+
function Vector2Editor({ value, onChange, min, max, step, }) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
return (_jsxs("div", { style: { display: 'flex', gap: 2 }, children: [_jsx(NumberInput, { value: (_a = value === null || value === void 0 ? void 0 : value[0]) !== null && _a !== void 0 ? _a : 0, onChange: x => { var _a; return onChange([x, (_a = value === null || value === void 0 ? void 0 : value[1]) !== null && _a !== void 0 ? _a : 0]); }, min: min, max: max, step: step, style: { width: '100%', minWidth: 0, boxSizing: 'border-box' } }), _jsx(NumberInput, { value: (_b = value === null || value === void 0 ? void 0 : value[1]) !== null && _b !== void 0 ? _b : 0, onChange: y => { var _a; return onChange([(_a = value === null || value === void 0 ? void 0 : value[0]) !== null && _a !== void 0 ? _a : 0, y]); }, min: min, max: max, step: step, style: { width: '100%', minWidth: 0, boxSizing: 'border-box' } })] }));
|
|
6
|
+
}
|
|
7
|
+
function SpriteComponentEditor({ component, onUpdate, }) {
|
|
8
|
+
const fields = [
|
|
9
|
+
{
|
|
10
|
+
name: 'center',
|
|
11
|
+
type: 'custom',
|
|
12
|
+
label: 'Center',
|
|
13
|
+
render: ({ value, onChange }) => (_jsx(Vector2Editor, { value: value, onChange: onChange, min: 0, max: 1, step: 0.01 })),
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
return (_jsxs(_Fragment, { children: [_jsx(FieldRenderer, { fields: fields, values: component.properties, onChange: onUpdate }), _jsxs("div", { style: { marginTop: 8 }, children: [_jsx(BooleanField, { name: "emitClickEvent", label: "Emit Click Event", values: component.properties, onChange: onUpdate, fallback: false }), component.properties.emitClickEvent ? (_jsx(StringField, { name: "clickEventName", label: "Click Event Name", values: component.properties, onChange: onUpdate, fallback: "node:click" })) : null] })] }));
|
|
17
|
+
}
|
|
18
|
+
const SpriteComponent = {
|
|
19
|
+
name: 'Sprite',
|
|
20
|
+
Editor: SpriteComponentEditor,
|
|
21
|
+
defaultProperties: {
|
|
22
|
+
center: [0.5, 0.5],
|
|
23
|
+
emitClickEvent: false,
|
|
24
|
+
clickEventName: 'node:click',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export default SpriteComponent;
|
|
@@ -1,28 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
1
|
+
// biome-ignore assist/source/organizeImports: <in order of display in the editor>
|
|
2
|
+
import TransformComponent from "./TransformComponent";
|
|
3
|
+
import GeometryComponent from "./GeometryComponent";
|
|
4
|
+
import BufferGeometryComponent from "./BufferGeometryComponent";
|
|
5
|
+
import ModelComponent from "./ModelComponent";
|
|
6
|
+
import SpriteComponent from "./SpriteComponent";
|
|
7
|
+
import TextComponent from "./TextComponent";
|
|
8
|
+
import MaterialComponent from "./MaterialComponent";
|
|
9
|
+
import SpotLightComponent from "./SpotLightComponent";
|
|
10
|
+
import PointLightComponent from "./PointLightComponent";
|
|
11
|
+
import DirectionalLightComponent from "./DirectionalLightComponent";
|
|
12
|
+
import AmbientLightComponent from "./AmbientLightComponent";
|
|
13
|
+
import EnvironmentComponent from "./EnvironmentComponent";
|
|
14
|
+
import CameraComponent from "./CameraComponent";
|
|
15
|
+
import SoundComponent from "./SoundComponent";
|
|
16
|
+
import DataComponent from "./DataComponent";
|
|
17
|
+
// this controls the order of components in the editor, and also which components are available to add
|
|
15
18
|
export const builtinComponents = [
|
|
16
19
|
TransformComponent,
|
|
20
|
+
// geometry components
|
|
17
21
|
GeometryComponent,
|
|
18
22
|
BufferGeometryComponent,
|
|
19
23
|
ModelComponent,
|
|
24
|
+
SpriteComponent,
|
|
20
25
|
TextComponent,
|
|
26
|
+
// material components
|
|
21
27
|
MaterialComponent,
|
|
28
|
+
// light components
|
|
22
29
|
SpotLightComponent,
|
|
23
30
|
PointLightComponent,
|
|
24
31
|
DirectionalLightComponent,
|
|
25
32
|
AmbientLightComponent,
|
|
33
|
+
// other components
|
|
26
34
|
EnvironmentComponent,
|
|
27
35
|
CameraComponent,
|
|
28
36
|
SoundComponent,
|