gpt4 book ai didi

javascript - 三个JS boxGeometry,渲染警告: Render count or primcount is 0

转载 作者:行者123 更新时间:2023-12-02 14:44:14 26 4
gpt4 key购买 nike

我试图将数据从 html 表单传递到代表 boxGeometry 的 x、y 和 z 维度的三个参数。当我手动设置参数值时它工作正常,但当参数通过表单中输入的值设置时则不行。

HTML

    <form>
<input type="text" name="valueX" id="valueX">
ValueX<br>
<input type="text" name="valueY" id="valueY">
ValueY<br>
<input type="text" name="valueZ" id="valueZ">
ValueZ<br>
</form>
<button onclick="render()">Render that box!</button>

JS

var geometry = newTHREE.BoxGeometry(parseInt(document.getElementById('valueX').value) ,parseInt(document.getElementById('valueY').value) ,parseInt(document.getElementById('valueZ').value));

var material = new THREE.MeshLambertMaterial({color:0x00ff20});

var cube = new THREE.Mesh(geometry,material);

scene.add(cube);

function render (){
cube.rotation.x += 1;
cube.rotation.y += 1;
renderer.render(scene,camera);
}

最佳答案

<button onclick="go()">Render that box!</button>


function go() {

var geometry = new THREE.BoxGeometry( parseInt(document.getElementById('valueX').value), parseInt(document.getElementById('valueY').value), parseInt(document.getElementById('valueZ').value) );

var material = new THREE.MeshLambertMaterial( { color:0x00ff20 } );

var cube = new THREE.Mesh( geometry, material );

scene.add( cube );

render();

}

三.js r.75

关于javascript - 三个JS boxGeometry,渲染警告: Render count or primcount is 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36746319/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com