Skip to content

Commit b7ca8f9

Browse files
committed
imp: prim improvements
1 parent 2e499ec commit b7ca8f9

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

examples/prim-switcher.js

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,15 @@ app.configure([
9090
step: 0.05,
9191
initial: 0.5,
9292
},
93-
{
94-
type: 'toggle',
95-
key: 'emissive',
96-
label: 'Emissive (Glow)',
97-
initial: false,
98-
},
9993
{
10094
type: 'range',
10195
key: 'emissiveIntensity',
10296
label: 'Glow Intensity',
10397
min: 0,
104-
max: 3,
98+
max: 10,
10599
step: 0.1,
106100
initial: 1,
107101
},
108-
{
109-
type: 'toggle',
110-
key: 'doubleside',
111-
label: 'Double Sided',
112-
initial: false,
113-
},
114102
{
115103
type: 'button',
116104
key: 'reset',
@@ -137,16 +125,26 @@ const currentPrim = app.create('prim', {
137125
texture: props.texture?.url,
138126
metalness: props.metalness ?? 0.5,
139127
roughness: props.roughness ?? 0.5,
140-
emissive: props.emissive ? props.color || '#4488ff' : null,
141-
emissiveIntensity: props.emissiveIntensity || 1,
142-
doubleside: props.doubleside || false,
128+
emissive: props.color || '#4488ff',
129+
emissiveIntensity: props.emissiveIntensity || 0,
130+
doubleside: props.primType === 'plane',
143131
castShadow: true,
144132
receiveShadow: true,
145133
})
146134
currentPrim.position.y += props.scaleY / 2
147135

148136
app.add(currentPrim)
149137

138+
// for (let i = 0; i < 10000; i++) {
139+
// const c = currentPrim.clone(true)
140+
// c.position.set(
141+
// num(-300, 300, 3),
142+
// num(0, 10, 3),
143+
// num(-300, 300, 3),
144+
// )
145+
// app.add(c)
146+
// }
147+
150148
app.on('update', dt => {
151149
// Auto rotate if enabled
152150
if (props.rotate && currentPrim) {
@@ -159,7 +157,7 @@ const info = app.create('ui', {
159157
width: 300,
160158
height: 50,
161159
size: 0.01,
162-
position: [0, 5, 0],
160+
position: [0, 3, 0],
163161
billboard: 'y',
164162
backgroundColor: 'rgba(0, 0, 0, 0.8)',
165163
borderRadius: 10,
@@ -187,9 +185,9 @@ info.add(title)
187185
info.add(subtitle)
188186
app.add(info)
189187

190-
console.log('Primitive Switcher ready!')
191-
console.log('Use the props panel in your browser to:')
192-
console.log('- Switch between primitive types')
193-
console.log('- Adjust scale, color, and materials')
194-
console.log('- Toggle rotation and glow effects')
195-
console.log('- Current primitive:', props.primType || 'box')
188+
// console.log('Primitive Switcher ready!')
189+
// console.log('Use the props panel in your browser to:')
190+
// console.log('- Switch between primitive types')
191+
// console.log('- Adjust scale, color, and materials')
192+
// console.log('- Toggle rotation and glow effects')
193+
// console.log('- Current primitive:', props.primType || 'box')

src/core/nodes/Prim.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ const applyTexture = (material, textureUrl, loader) => {
146146
let texture = loader.get('texture', textureUrl)
147147
if (!texture) texture = await loader.load('texture', textureUrl)
148148
material.map = texture
149+
material._texApplied = true
149150
resolve()
150151
})
151152
}

0 commit comments

Comments
 (0)