N
N
Nikolai Chuprik2018-02-23 16:28:44
Canvas
Nikolai Chuprik, 2018-02-23 16:28:44

How to assign three.js to display content?

In all three.js examples, the canvas block is inserted programmatically, something like this:

var figure = document.getElementById ('....');   // блочный элемент, куда вставляю рендер
figure.appendChild( renderer.domElement );


But this is not good for me, because. Vue is used, and operating on the DOM that bypasses Vue leads to all kinds of trouble.

I want to write directly in HTML and somehow assign this canvas for three.js render output <canvas id="threejs_here"> </canvas>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-02-23
@choupa

I want to write directly in HTML and somehow assign this canvas for three.js render output<canvas id="threejs_here"> </canvas>

No problems. Set your canvas to ref: And specify it when creating the renderer:
<canvas ref="threejs"></canvas>
new THREE.WebGLRenderer({
  canvas: this.$refs.threejs,
})

Somehow so .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question