0

I am new to new features of HTML5.
Is it possible to embed existing webgl page to my page?
Am I going to the right direction?

 <!DOCTYPE html>
 <html>
 <head lang="en">
<meta charset="UTF-8">
<title></title>

<script>
    var camera, scene, loader;
    function init() {
        scene = new THREE.Scene();
        camera = new THREE.perspectiveCamera();
        loader = new THREE.ImageLoader("http.......");
        scene.add(camera);
        scene.add(loader);

    }
</script>

Thanks

1 Answer 1

2

You have to use ImageUtils if you want to add an image as texture.

var texture = THREE.ImageUtils.loadTexture( "textures/pic.png" );
var material = new THREE.MeshPhongMaterial( { map: texture } );

// you can edit texture settings
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( 512, 512 );

var mesh = new THREE.Mesh( geometry, material );
scene.add(mesh);

If you have another three.js scene and you want to load that into your application, have a look at the loader / scene example from three.js.

If you want to embed a whole page, you could consider using the iframe-Tag.

<iframe src="http..."></iframe>
Sign up to request clarification or add additional context in comments.

4 Comments

So the texture can be threejs.org/examples/#webgl_animation_cloth or it can only be a .png, .jpg?
No, a website can't be a texture. But as I said you can include that webpage using an iframe tag: <iframe src="http://threejs.org/examples/webgl_animation_cloth"></iframe>
is it possible to add this iframe to canvas or scene and play with it?
There is no need, because the iframe already includes the canvas and scene from the referenced page. If you, however, want to manipulate the external scene, you have to copy the source code that it was made of and modify that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.