This commit is contained in:
syuilo 2026-05-24 05:48:13 +09:00
commit 05e1a43a1c
5 changed files with 64 additions and 124 deletions

View file

@ -17,16 +17,9 @@ export const ductRailSpotLights = defineObject({
type: 'color',
label: 'Body color',
},
lightColor: {
type: 'color',
label: 'Light color',
},
lightBrightness: {
type: 'range',
label: 'Light brightness',
min: 0,
max: 1,
step: 0.01,
light: {
type: 'light',
label: 'Light',
},
angleV: {
type: 'range',
@ -45,8 +38,10 @@ export const ductRailSpotLights = defineObject({
},
default: {
bodyColor: [0.05, 0.05, 0.05],
lightColor: [1, 0.5, 0.2],
lightBrightness: 0.2,
light: {
color: [1, 0.5, 0.2],
brightness: 0.2,
},
angleV: 0.75,
angleH: 0.5,
},
@ -73,31 +68,21 @@ export const ductRailSpotLights = defineObject({
lights.push(light);
}
const applyLightColor = () => {
const [r, g, b] = options.lightColor;
const applyLight = () => {
const [r, g, b] = options.light.color;
for (const light of lights) {
light.diffuse = new BABYLON.Color3(r, g, b);
light.intensity = 5 * options.light.brightness * WORLD_SCALE * WORLD_SCALE;
light.range = remap(options.light.brightness, 0, 1, cm(200), cm(400)) * getLightRangeFactorByGraphicsQuality(graphicsQuality);
}
for (const lamp of lamps) {
const emissive = lamp.material as BABYLON.PBRMaterial;
emissive.emissiveColor = new BABYLON.Color3(r, g, b);
emissive.emissiveIntensity = options.light.brightness * 100;
}
};
applyLightColor();
const applyLightBrightness = () => {
for (const light of lights) {
light.intensity = 5 * options.lightBrightness * WORLD_SCALE * WORLD_SCALE;
light.range = remap(options.lightBrightness, 0, 1, cm(200), cm(400)) * getLightRangeFactorByGraphicsQuality(graphicsQuality);
}
for (const lamp of lamps) {
const emissive = lamp.material as BABYLON.PBRMaterial;
emissive.emissiveIntensity = options.lightBrightness * 100;
}
};
applyLightBrightness();
applyLight();
const shades = model.findMeshes('__X_SHADE__');
@ -117,8 +102,7 @@ export const ductRailSpotLights = defineObject({
onOptionsUpdated: ([k, v]) => {
switch (k) {
case 'bodyColor': applyBodyColor(); break;
case 'lightColor': applyLightColor(); break;
case 'lightBrightness': applyLightBrightness(); break;
case 'light': applyLight(); break;
case 'angleV':
case 'angleH':
applyAngle();

View file

@ -17,16 +17,9 @@ export const spotLight = defineObject({
type: 'color',
label: 'Body color',
},
lightColor: {
type: 'color',
label: 'Light color',
},
lightBrightness: {
type: 'range',
label: 'Light brightness',
min: 0,
max: 1,
step: 0.01,
light: {
type: 'light',
label: 'Light',
},
angleV: {
type: 'range',
@ -45,8 +38,10 @@ export const spotLight = defineObject({
},
default: {
bodyColor: [0.05, 0.05, 0.05],
lightColor: [1, 0.5, 0.2],
lightBrightness: 0.2,
light: {
color: [1, 0.5, 0.2],
brightness: 0.2,
},
angleV: 0.75,
angleH: 0.5,
},
@ -69,23 +64,17 @@ export const spotLight = defineObject({
light.radius = cm(8);
if (lc != null) lc.addLight(light);
const applyLightColor = () => {
const [r, g, b] = options.lightColor;
const applyLight = () => {
const [r, g, b] = options.light.color;
light.diffuse = new BABYLON.Color3(r, g, b);
light.intensity = 5 * options.light.brightness * WORLD_SCALE * WORLD_SCALE;
light.range = remap(options.light.brightness, 0, 1, cm(200), cm(400)) * getLightRangeFactorByGraphicsQuality(graphicsQuality);
const emissive = lamp.material as BABYLON.PBRMaterial;
emissive.emissiveColor = new BABYLON.Color3(r, g, b);
emissive.emissiveIntensity = options.light.brightness * 100;
};
applyLightColor();
const applyLightBrightness = () => {
light.intensity = 5 * options.lightBrightness * WORLD_SCALE * WORLD_SCALE;
light.range = remap(options.lightBrightness, 0, 1, cm(200), cm(400)) * getLightRangeFactorByGraphicsQuality(graphicsQuality);
const emissive = lamp.material as BABYLON.PBRMaterial;
emissive.emissiveIntensity = options.lightBrightness * 100;
};
applyLightBrightness();
applyLight();
const shade = model.findMesh('__X_SHADE__');
@ -103,8 +92,7 @@ export const spotLight = defineObject({
onOptionsUpdated: ([k, v]) => {
switch (k) {
case 'bodyColor': applyBodyColor(); break;
case 'lightColor': applyLightColor(); break;
case 'lightBrightness': applyLightBrightness(); break;
case 'light': applyLight(); break;
case 'angleV':
case 'angleH':
applyAngle();

View file

@ -17,16 +17,9 @@ export const wallMountSpotLight = defineObject({
type: 'color',
label: 'Body color',
},
lightColor: {
type: 'color',
label: 'Light color',
},
lightBrightness: {
type: 'range',
label: 'Light brightness',
min: 0,
max: 1,
step: 0.01,
light: {
type: 'light',
label: 'Light',
},
angleV: {
type: 'range',
@ -45,8 +38,10 @@ export const wallMountSpotLight = defineObject({
},
default: {
bodyColor: [0.05, 0.05, 0.05],
lightColor: [1, 0.5, 0.2],
lightBrightness: 0.5,
light: {
color: [1, 0.5, 0.2],
brightness: 0.5,
},
angleV: 0.1,
angleH: 0.5,
},
@ -72,23 +67,17 @@ export const wallMountSpotLight = defineObject({
light.radius = cm(5);
if (lc != null) lc.addLight(light);
const applyLightColor = () => {
const [r, g, b] = options.lightColor;
const applyLight = () => {
const [r, g, b] = options.light.color;
light.diffuse = new BABYLON.Color3(r, g, b);
const emissive = lamp.material as BABYLON.PBRMaterial;
emissive.emissiveColor = new BABYLON.Color3(r, g, b);
};
applyLightColor();
const applyLightBrightness = () => {
light.intensity = 1 * options.lightBrightness * WORLD_SCALE * WORLD_SCALE;
light.intensity = 1 * options.light.brightness * WORLD_SCALE * WORLD_SCALE;
light.range = cm(200) * getLightRangeFactorByGraphicsQuality(graphicsQuality);
const emissive = lamp.material as BABYLON.PBRMaterial;
emissive.emissiveIntensity = options.lightBrightness * 20;
emissive.emissiveColor = new BABYLON.Color3(r, g, b);
emissive.emissiveIntensity = options.light.brightness * 20;
};
applyLightBrightness();
applyLight();
const applyAngle = () => {
bodyMesh.rotationQuaternion = null;
@ -104,8 +93,7 @@ export const wallMountSpotLight = defineObject({
onOptionsUpdated: ([k, v]) => {
switch (k) {
case 'bodyColor': applyBodyColor(); break;
case 'lightColor': applyLightColor(); break;
case 'lightBrightness': applyLightBrightness(); break;
case 'light': applyLight(); break;
case 'angleV':
case 'angleH':
applyAngle();

View file

@ -69,35 +69,27 @@ export const woodRingFloorLamp = defineObject({
lights.push(light);
}
const applyLightColor = () => {
const applyLight = () => {
for (const light of lights) {
light.diffuse = new BABYLON.Color3(options.light.color[0], options.light.color[1], options.light.color[2]);
}
for (const lamp of lamps) {
(lamp.material as BABYLON.PBRMaterial).emissiveColor = new BABYLON.Color3(options.light.color[0], options.light.color[1], options.light.color[2]);
}
};
applyLightColor();
const applyLightBrightness = () => {
for (const light of lights) {
light.intensity = 1 * options.light.brightness * WORLD_SCALE * WORLD_SCALE;
light.range = cm(200) * getLightRangeFactorByGraphicsQuality(graphicsQuality);
}
for (const lamp of lamps) {
(lamp.material as BABYLON.PBRMaterial).emissiveColor = new BABYLON.Color3(options.light.color[0], options.light.color[1], options.light.color[2]);
(lamp.material as BABYLON.PBRMaterial).emissiveIntensity = options.light.brightness * 10;
}
};
applyLightBrightness();
applyLight();
return {
onOptionsUpdated: ([k, v]) => {
applyShadeColor();
applyBodyColor();
applyLightColor();
applyLightBrightness();
switch (k) {
case 'shadeMat': applyShadeColor(); break;
case 'bodyMat': applyBodyColor(); break;
case 'light': applyLight(); break;
}
},
interactions: {},
dispose: () => {

View file

@ -25,16 +25,9 @@ export const woodRingsPendantLight = defineObject({
type: 'color',
label: 'Body color',
},
lightColor: {
type: 'color',
label: 'Light color',
},
lightBrightness: {
type: 'range',
label: 'Light brightness',
min: 0,
max: 1,
step: 0.01,
light: {
type: 'light',
label: 'Light',
},
length: {
type: 'range',
@ -47,8 +40,10 @@ export const woodRingsPendantLight = defineObject({
default: {
shadeColor: [0.21, 0.04, 0],
bodyColor: [0.05, 0.05, 0.05],
lightColor: [1, 0.5, 0.2],
lightBrightness: 0.5,
light: {
color: [1, 0.5, 0.2],
brightness: 0.5,
},
length: 0.2,
},
},
@ -86,23 +81,17 @@ export const woodRingsPendantLight = defineObject({
//const flare03 = new BABYLON.LensFlare(0.15, -1.5, new BABYLON.Color3(...options.lightColor), '/client-assets/world/lensflare.png', lensFlareSystem);
//const flare04 = new BABYLON.LensFlare(0.3, -2, new BABYLON.Color3(...options.lightColor), '/client-assets/world/lensflare.png', lensFlareSystem);
const applyLightColor = () => {
const [r, g, b] = options.lightColor;
const applyLight = () => {
const [r, g, b] = options.light.color;
light.diffuse = new BABYLON.Color3(r, g, b);
const emissive = lamp.material as BABYLON.PBRMaterial;
emissive.emissiveColor = new BABYLON.Color3(r, g, b);
};
applyLightColor();
const applyLightBrightness = () => {
light.intensity = 2 * options.lightBrightness * WORLD_SCALE * WORLD_SCALE;
light.intensity = 2 * options.light.brightness * WORLD_SCALE * WORLD_SCALE;
light.range = cm(200) * getLightRangeFactorByGraphicsQuality(graphicsQuality);
const emissive = lamp.material as BABYLON.PBRMaterial;
emissive.emissiveIntensity = options.lightBrightness * 20;
emissive.emissiveColor = new BABYLON.Color3(r, g, b);
emissive.emissiveIntensity = options.light.brightness * 20;
};
applyLightBrightness();
applyLight();
const mainNode = model.findTransformNode('__X_MAIN__');
const codeMesh = model.findMesh('__X_CODE__');
@ -120,8 +109,7 @@ export const woodRingsPendantLight = defineObject({
switch (k) {
case 'shadeColor': applyShadeColor(); break;
case 'bodyColor': applyBodyColor(); break;
case 'lightColor': applyLightColor(); break;
case 'lightBrightness': applyLightBrightness(); break;
case 'light': applyLight(); break;
case 'length': applyLength(); break;
}
},