Home › Forums › General Questions › Can’t Animate Light Scale/Size
- This topic has 4 replies, 2 voices, and was last updated 8 months, 2 weeks ago by Brameister.
-
AuthorPosts
-
2024-04-09 at 4:53 pm #72215BrameisterParticipant
It seems Verge3D does recognize any Position or Rotation animation when it comes to lights, but not a Scale animation. I tried animating both Scale and the actual Size parameter in the Object Data Properties in Blender, but neither worked. Is that right? Is there no way to animate changes in a light source’s size?
2024-04-09 at 6:34 pm #72216kdvParticipantWhat do you expect to get from scaling a light source? It has some sense only for area or spot lights. Point lights and directional lights has no dimensions…
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2024-04-10 at 10:23 pm #72254BrameisterParticipantI’m using area lights representing LED strips built into furniture. For example, when the furniture’s width changes, I need the lenghth of the area light to change accordingly
2024-04-11 at 5:51 am #72260kdvParticipantArea lights also have no dimensions and it’s useless to scale them (0*20=0). But they have two specific properties: width and height. You can control those properties via JS.
https://www.soft8soft.com/docs/api/en/lights/RectAreaLight.htmlPuzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2024-04-11 at 2:56 pm #72281BrameisterParticipantRight on!
I think I figured it out with your help. For anyone else that may encounter this problem, here’s the code I used in an Exec Script puzzle that worked for me:
// Define a function to update LED widths
function updateLEDWidths() {
// Access the slider in the parent document
var sliderValue = parent.document.getElementById(‘your_element_id’).value;// Map the slider value ([your range of slider values (e.g. 10 to 20)]) to the LED width ([range of Area Light X values (e.g 0.45 to 0.86)])
var ledWidth = mapRange(sliderValue, 10, 20, 0.45, 0.86);// Update the width of each Area light
var ledNames = [‘LED 1’, ‘LED 2’, ‘LED 3’, ‘LED 4’];
ledNames.forEach(function(ledName) {
// Assuming ‘app’ is your Verge3D app instance accessible in this context
var led = app.scene.getObjectByName(ledName);
if (led && led.isRectAreaLight) {
led.width = ledWidth;
}
});
}// Helper function to map a value from one range to another
function mapRange(value, inMin, inMax, outMin, outMax) {
return (value – inMin) * (outMax – outMin) / (inMax – inMin) + outMin;
}// Ensure this code runs after the Verge3D app is fully initialized
// You might need to place this inside a function that’s called after app initialization
updateLEDWidths();// Add an event listener to the slider in the parent document to update LED widths on change
parent.document.getElementById(your_element_id’).addEventListener(‘input’, updateLEDWidths); -
AuthorPosts
- You must be logged in to reply to this topic.