three.js复制网格加载对象JavaScript(three.js copy mesh loaded object JavaScript)
我使用three.js r59,我无法尝试复制加载的模型。 我想要实现的是循环和创建几个模型。我将担心稍后将纹理应用于它们。
for (var i=0; i<5-1; i++){ var loader = new THREE.OBJLoader( ); loader.load( 'mod/bookH.obj',function ( object ) { object.traverse( function ( child ) { if ( child instanceof THREE.Mesh ) { child.castShadow = true; console.log(i); //child.material.map = texture; //dont need right now } } ); //below works object.position.set( 1 * 0, 0, 5 ); scene.add( object ); //below doesn't work and no error... var testMesh = new.THREE.Object3D(object); scene.add(testMesh); }); } }
Im using three.js r59, Im having trouble trying to copy a loaded model. What im trying to achieve is to loop and create several models.I will worry about applying texture to them later..
for (var i=0; i<5-1; i++){ var loader = new THREE.OBJLoader( ); loader.load( 'mod/bookH.obj',function ( object ) { object.traverse( function ( child ) { if ( child instanceof THREE.Mesh ) { child.castShadow = true; console.log(i); //child.material.map = texture; //dont need right now } } ); //below works object.position.set( 1 * 0, 0, 5 ); scene.add( object ); //below doesn't work and no error... var testMesh = new.THREE.Object3D(object); scene.add(testMesh); }); } }
原文:https://stackoverflow.com/questions/19592361
更新时间:2023-11-16 18:11
最满意答案
试着用这个:
$info2['category']=$info; echo json_encode($info2);
Try to use this:
$info2['category']=$info; echo json_encode($info2);
相关问答
更多-
$key = $db->getKeyPermissions(); if ($key != false) { $response["error"] = FALSE; for($i = 0; $i < count($key); $i++){ $response["key"][$i] = array(); $response["key"][$i]["endpoint_description"] = $key[$i]["endpoint_description"]; $re ...
-
json_encode稀疏的PHP数组作为JSON数组,不是JSON对象(json_encode sparse PHP array as JSON array, not JSON object)[2023-12-20]
您正在观察此行为,因为您的数组不是顺序的 - 它具有键0和2 ,但不具有1作为键。 只有数字指标是不够的。 如果您的PHP数组是顺序的, json_encode将仅将您的PHP数组编码为JSON数组,也就是说,如果它的键为0,1,2,3,... 您可以使用array_values函数依次重新索引数组,以获取所需的行为。 例如,以下代码在您的用例中成功运行: echo json_encode(array_values($input)). You are observing this behaviour be ... -
json_decode()需要一个额外的参数来解码数组。 json_decode($json, true) json_decode() needs an extra parameter to decode to an array. json_decode($json, true)
-
试试这个,就像@deceze说的那样。 $data = json_encode(array( "username"=> "Email Notifier", "mrkdwn"=> true, "icon_emoji"=> ":email:", "text" => "*Name:* {$posted_data["your-name"]}\n*Email:* {$posted_data["your-email"]}\n*Subject:* {$posted_data["your-subject"] ...
-
试着用这个: $info2['category']=$info; echo json_encode($info2); Try to use this: $info2['category']=$info; echo json_encode($info2);
-
现在,响应只是被视为一个字符串(数据类型)。 这就是为什么response.string不起作用的原因。 您可以通过添加以下内容来说明: console.log( typeof response ); 所以别忘了放: header('Content-Type: application/json'); 在你里面if阻止: 而你在if块(isset和response )上有一个拼写错误: if ( isset ($_POST['func']) && $_POST['func'] === 'genString ...
-
它看起来像“ProductComment”的所有属性都是私有的,所以当谈到JSON编码时,您会得到: [{}, {}] 这基本上是一个数组,其中有两个空对象。 你需要做的是告诉PHP在序列化(或者json编码)时哪些属性可以并且应该保留。 为此,您需要将__sleep()魔术方法添加到您的类中:( http://uk.php.net/__sleep ) It looks like all of the properties of "ProductComment" are private, so when ...
-
这是因为用户属性是私有的。 如果你将它们公之于众,他们就会展示 但是,请确定是否要将它们更改为公开,因为它们可能是私有的。 Its because the user properties are private. If you make them public they will show. However, decide if it you want to change them to public because they are probably private for a reason.
-
将非关联数组传递给json_encode()时会发生什么?(What happens when you pass a non-associative array to json_encode()?)[2023-07-24]
如果您尝试使用正确的对象表示法,请尝试以下操作: echo json_encode($arr,JSON_FORCE_OBJECT); 输出: {"0":"One", "1":"Two", "2":"Three"} 请参阅json_encode()选项 If you're trying to get it in proper object notation, try this: echo json_encode($arr,JSON_FORCE_OBJECT); Output: {"0":"One", " ... -
两个字符串完全相同,SplFixedArray只有一个不同的存储方式,因为它是一个FIXED数组。 简单的演示 另请务必阅读手册。 如果你启动SplFixedArray(它是一个类,而不是一个函数),你会获得一个对象作为回报。 手册: http : //php.net/manual/en/class.splfixedarray.php The two string are exactly the same, SplFixedArray only has a little different way of s ...