@archvisioninc/canvas 3.2.1 → 3.2.3
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.
|
@@ -1162,7 +1162,9 @@ export const updateLighting = inboundData => {
|
|
|
1162
1162
|
diffuse,
|
|
1163
1163
|
specular,
|
|
1164
1164
|
radius,
|
|
1165
|
-
intensity
|
|
1165
|
+
intensity,
|
|
1166
|
+
distance,
|
|
1167
|
+
rotation
|
|
1166
1168
|
} = payload;
|
|
1167
1169
|
const light = scene.getLightByName(id);
|
|
1168
1170
|
if (!_.isEmpty(transforms)) {
|
|
@@ -1174,8 +1176,10 @@ export const updateLighting = inboundData => {
|
|
|
1174
1176
|
dirY,
|
|
1175
1177
|
dirZ
|
|
1176
1178
|
} = transforms;
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
+
const isPosition = tx !== undefined && ty !== undefined && tz !== undefined;
|
|
1180
|
+
const isDirection = dirX !== undefined && dirY !== undefined && dirZ !== undefined;
|
|
1181
|
+
if (isPosition) light.position = newVector(tx, ty, tz);
|
|
1182
|
+
if (isDirection) light.direction = newVector(dirX, dirY, dirZ);
|
|
1179
1183
|
}
|
|
1180
1184
|
if (target) {
|
|
1181
1185
|
light.setDirectionToTarget(target);
|
|
@@ -1205,5 +1209,26 @@ export const updateLighting = inboundData => {
|
|
|
1205
1209
|
if (intensity !== undefined) {
|
|
1206
1210
|
light.intensity = intensity;
|
|
1207
1211
|
}
|
|
1212
|
+
if (distance !== undefined) {
|
|
1213
|
+
const rotation = light?.rotation || 0;
|
|
1214
|
+
const angleRad = rotation * Math.PI / 180;
|
|
1215
|
+
light.position = newVector(distance * Math.cos(angleRad), 5, distance * Math.sin(angleRad));
|
|
1216
|
+
light.setDirectionToTarget(newVector(0, 0, 0));
|
|
1217
|
+
light.distance = distance;
|
|
1218
|
+
}
|
|
1219
|
+
if (rotation !== undefined) {
|
|
1220
|
+
const {
|
|
1221
|
+
position
|
|
1222
|
+
} = light;
|
|
1223
|
+
const {
|
|
1224
|
+
x,
|
|
1225
|
+
y,
|
|
1226
|
+
z
|
|
1227
|
+
} = position;
|
|
1228
|
+
const distance = light?.distance || Math.sqrt(Math.pow(Math.abs(x), 2) + Math.pow(Math.abs(y), 2) + Math.pow(Math.abs(z), 2));
|
|
1229
|
+
light.position = newVector(distance * Math.cos(angleRad), 5, distance * Math.sin(angleRad));
|
|
1230
|
+
light.setDirectionToTarget(newVector(0, 0, 0));
|
|
1231
|
+
light.rotation = rotation;
|
|
1232
|
+
}
|
|
1208
1233
|
newMetaDataEntry('lights', buildLightsArray());
|
|
1209
1234
|
};
|
|
@@ -610,7 +610,13 @@ export const buildMaterialsArray = () => {
|
|
|
610
610
|
};
|
|
611
611
|
export const buildLightsArray = () => {
|
|
612
612
|
const lights = scene.lights;
|
|
613
|
-
return lights.map(light =>
|
|
613
|
+
return lights.map(light => {
|
|
614
|
+
return {
|
|
615
|
+
...light.serialize(),
|
|
616
|
+
rotation: light?.rotation ?? 0,
|
|
617
|
+
distance: light?.distance ?? Math.sqrt(Math.pow(Math.abs(x), 2) + Math.pow(Math.abs(y), 2) + Math.pow(Math.abs(z), 2))
|
|
618
|
+
};
|
|
619
|
+
});
|
|
614
620
|
};
|
|
615
621
|
const billboardScreenshot = view => {
|
|
616
622
|
const camera = scene.activeCamera.clone(view);
|
package/package.json
CHANGED
|
@@ -1169,14 +1169,16 @@ export const updatePublish = inboundData => {
|
|
|
1169
1169
|
|
|
1170
1170
|
export const updateLighting = inboundData => {
|
|
1171
1171
|
const { payload } = inboundData;
|
|
1172
|
-
const { id, transforms, target, enable, diffuse, specular, radius, intensity } = payload;
|
|
1172
|
+
const { id, transforms, target, enable, diffuse, specular, radius, intensity, distance, rotation } = payload;
|
|
1173
1173
|
|
|
1174
1174
|
const light = scene.getLightByName(id);
|
|
1175
1175
|
|
|
1176
1176
|
if (!_.isEmpty(transforms)) {
|
|
1177
1177
|
const { tx, ty, tz, dirX, dirY, dirZ } = transforms;
|
|
1178
|
-
|
|
1179
|
-
|
|
1178
|
+
const isPosition = tx !== undefined && ty !== undefined && tz !== undefined;
|
|
1179
|
+
const isDirection = dirX !== undefined && dirY !== undefined && dirZ !== undefined;
|
|
1180
|
+
if (isPosition) light.position = newVector(tx, ty, tz);
|
|
1181
|
+
if (isDirection) light.direction = newVector(dirX, dirY, dirZ);
|
|
1180
1182
|
}
|
|
1181
1183
|
|
|
1182
1184
|
if (target) {
|
|
@@ -1205,5 +1207,22 @@ export const updateLighting = inboundData => {
|
|
|
1205
1207
|
light.intensity = intensity;
|
|
1206
1208
|
}
|
|
1207
1209
|
|
|
1210
|
+
if (distance !== undefined) {
|
|
1211
|
+
const rotation = light?.rotation || 0;
|
|
1212
|
+
const angleRad = (rotation * Math.PI) / 180
|
|
1213
|
+
light.position = newVector(distance * Math.cos(angleRad), 5, distance * Math.sin(angleRad));
|
|
1214
|
+
light.setDirectionToTarget(newVector(0, 0, 0));
|
|
1215
|
+
light.distance = distance;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
if (rotation !== undefined) {
|
|
1219
|
+
const { position } = light;
|
|
1220
|
+
const { x, y, z } = position;
|
|
1221
|
+
const distance = light?.distance || Math.sqrt(Math.pow(Math.abs(x), 2) + Math.pow(Math.abs(y), 2) + Math.pow(Math.abs(z), 2));
|
|
1222
|
+
light.position = newVector(distance * Math.cos(angleRad), 5, distance * Math.sin(angleRad));
|
|
1223
|
+
light.setDirectionToTarget(newVector(0, 0, 0));
|
|
1224
|
+
light.rotation = rotation;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1208
1227
|
newMetaDataEntry('lights', buildLightsArray())
|
|
1209
1228
|
};
|
|
@@ -668,7 +668,13 @@ export const buildMaterialsArray = () => {
|
|
|
668
668
|
|
|
669
669
|
export const buildLightsArray = () => {
|
|
670
670
|
const lights = scene.lights;
|
|
671
|
-
return lights.map(light =>
|
|
671
|
+
return lights.map(light => {
|
|
672
|
+
return {
|
|
673
|
+
...light.serialize(),
|
|
674
|
+
rotation: light?.rotation ?? 0,
|
|
675
|
+
distance: light?.distance ?? Math.sqrt(Math.pow(Math.abs(x), 2) + Math.pow(Math.abs(y), 2) + Math.pow(Math.abs(z), 2)),
|
|
676
|
+
};
|
|
677
|
+
});
|
|
672
678
|
};
|
|
673
679
|
|
|
674
680
|
const billboardScreenshot = view => {
|