HTML button that initializes the scene?

I’ve search for what seems like hours.

I have a scene on a asp.net page but I don’t want to load it right away. I want to start it after entering some inputs, and using those inputs when the scene starts.

Is this possible?

I think the easiest way would be just to hide the scene using JS until you want to show it. But there is no reason why you can’t load scene parts from the server based on the user’s input.

I have a button click event firing the function to start the render of the scene. But it starts still by itself.

function init()
{
Buttons = document.getElementById(‘Button’);

Buttons.onclick = function StartAnimation() 
{
    animate();
}
{
function animate()
{
requestAnimationFrame(animate);
render();
}
function render()
{
renderer.render(scene, camera);
}
animate();

When the page does start the scene is using the initial values of the sliders I have to create my geo. If I hit the button it changes those slider inputs to their initial value instead of using the desired values.

Are you sure your button doesn’t trigger a postback (can happen on ASP.Net when it is implemented as server side control)? That could explain the change to the sliders.

Yeah I did the "onclientclick=“return false” still refreshes the page…/

Got it to work with this…although I still want the scene to be inactive until I hit the button.


Buttons = document.getElementById("Button");

Buttons.onclick = function StartAnimation()
{

  //" input variables"

    animate();
}
//}
function animate()
{
    requestAnimationFrame(animate);
    render();
}
function render()
{
    renderer.render(scene, camera);
}
animate();

I was under the assumption that the scene wouldn’t display until the render function was called.

remove last line of your code?:

animate()

2 Likes

DUH!!!

That did it. Now I guess I can just hide the black blank scene until I hit the button…but now that I think of it having a blank scene with a grid doesn’t seem to bad.

Thank you so much for your help.

1 Like