# ZIM TextureActives for VR

**URL:** <https://discourse.threejs.org/t/zim-textureactives-for-vr/56338>\
**Category:** Resources\
**Tags:** webxr, interaction, vr, xr, textures\
**Created:** [September 24, 2023, 1:15am UTC](https://discourse.threejs.org/t/zim-textureactives-for-vr/56338 "2023-09-24T01:15:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danzen](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/danzen/32/39322_2.png) [@danzen](https://discourse.threejs.org/u/danzen)\
**Post date:** [September 24, 2023, 1:15am UTC](https://discourse.threejs.org/t/zim-textureactives-for-vr/56338/1 "2023-09-24T01:15:26Z")

</div>

![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/c/f/cf21c60d97e238abf5f84ef7f122c6e8e3c95db8.jpeg)

We can now add ZIM TextureActives to VR. ZIM is a 2D canvas framework that be added to three.js as interactive textures. This raycasts pointer data into ZIM. Now, we can raycast VR Controller data into ZIM - see [https://zimjs.com/015](https://zimjs.com/015) and try the VR link in a VR Headset browser - there is also a video capture link. The ZIM Three helper module now has XRControllers(), XRMovement() and XRTeleport() classes to make these in just a line or two of code!

Thanks three.js and others for making a dream come true. Also see our resource link for TextureActrives here: [ZIM TextureActives for Interactive Textures](https://discourse.threejs.org/t/zim-textureactives-for-interactive-textures/55746/)

Please let us know if you have any questions - and if you try it out, let us know how it goes. Cheers!

---

<div class="post-metadata">

**Author:** ![danzen](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/danzen/32/39322_2.png) [@danzen](https://discourse.threejs.org/u/danzen)\
**Post date:** [September 24, 2023, 2:43am UTC](https://discourse.threejs.org/t/zim-textureactives-for-vr/56338/2 "2023-09-24T02:43:35Z")

</div>

Here is a sample of what the code looks like. Usually we add more comments - but we stripped it down so you can see easily what is going on:

```javascript
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>ZIM VR Template with three.js</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">    
    </head>
	<body>

    <script type="module">

    // full template here https://zimjs.com/015/vr_template.html
    
    import zim from "https://zimjs.com/cdn/015/zim_three";

    new Frame(FIT, 1024, 768, black, black, ready);
    function ready() {
        
        const panel = new TextureActive(800,500).addTo();
        new Circle(100,blue).center(panel).drag(); 

        const three = new Three({
            width:window.innerWidth, 
            height:window.innerHeight, 
            cameraPosition:new THREE.Vector3(0,0,1),
            textureActive:true,
            xr:true
        });

        const renderer = three.renderer;
        const scene = three.scene;
        const camera = three.camera;

        const floor = new THREE.Mesh(
            new THREE.CircleGeometry(40, 32).rotateX(-Math.PI / 2),
            new THREE.MeshBasicMaterial({color:0x000000})
        );
        floor.position.y = -4;
        scene.add(floor);

        const controls = new OrbitControls(camera, renderer.domElement); // for non-vr
        
        const xrControllers = new XRControllers(three); // for vr
        xrControllers.on("xrconnected", () => {            
            const xrMovement = new XRMovement({
                three:three, 
                XRControllers:xrControllers, 
                radiusMax:40
            });
            new XRTeleport(three, xrControllers, xrMovement, floor, 4);
        });           

        // once for array of any TextureActive objects
        const textureActives = new TextureActives([panel], THREE, three, renderer, scene, camera, controls);        

        const canvasWindow = three.makePanel(panel, textureActives, .01); // .05 is scale
        canvasWindow.position.set(0,0,-5);
        scene.add(canvasWindow);

    }

		</script>
	</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![danzen](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/danzen/32/39322_2.png) [@danzen](https://discourse.threejs.org/u/danzen)\
**Post date:** [November 5, 2023, 4:08pm UTC](https://discourse.threejs.org/t/zim-textureactives-for-vr/56338/3 "2023-11-05T16:08:00Z")

</div>

Check out MultiPixel - a TextureActive shared pixel board in VR [Multi-Pixel - VR Experience with ZIM and three.js](https://zimjs.com/multipixel) - play with friends!

 ![vr_socket](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/b/b/bb895556e2bba11cde0087f16a4166ac7fd9ae89.jpeg)

---

<div class="post-metadata">

**Author:** ![danzen](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/danzen/32/39322_2.png) [@danzen](https://discourse.threejs.org/u/danzen)\
**Post date:** [May 31, 2024, 8:51pm UTC](https://discourse.threejs.org/t/zim-textureactives-for-vr/56338/4 "2024-05-31T20:51:56Z")

</div>

TextureActive Studio has just launched showing 35 examples of 2D interactivity in 3D and VR. See [TextureActive Studio - 2D Interactivity in 3D with ZIM in three.js](https://zimjs.com/studio). Put on your headsets and go through the examples in a VR Browser - so cool! Let us know what you think and if you have any questions, feel free to ask here or at the [ZIM Forum](https://forum.zimjs.com)

[![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/d/6/d68d368634ddca26196fa4ce5629433d2baac6e3.jpeg)](https://zimjs.com/studio)
