SkinnedMesh.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!DOCTYPE html>
  2. <html lang="ar">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body class="rtl">
  10. [page:Object3D] &rarr; [page:Mesh] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. شبكة لديها [page:Skeleton] مع [page:Bone bones] يمكن استخدامها بعد ذلك
  14. لتحريك رؤوس الهندسة.
  15. </p>
  16. <iframe id="scene" src="scenes/bones-browser.html"></iframe>
  17. <script>
  18. // iOS iframe auto-resize workaround
  19. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  20. const scene = document.getElementById( 'scene' );
  21. scene.style.width = getComputedStyle( scene ).width;
  22. scene.style.height = getComputedStyle( scene ).height;
  23. scene.setAttribute( 'scrolling', 'no' );
  24. }
  25. </script>
  26. <h2>مثال للكود</h2>
  27. <code>
  28. const geometry = new THREE.CylinderGeometry( 5, 5, 5, 5, 15, 5, 30 );
  29. // create the skin indices and skin weights manually
  30. // (typically a loader would read this data from a 3D model for you)
  31. const position = geometry.attributes.position;
  32. const vertex = new THREE.Vector3();
  33. const skinIndices = [];
  34. const skinWeights = [];
  35. for ( let i = 0; i < position.count; i ++ ) {
  36. vertex.fromBufferAttribute( position, i );
  37. // compute skinIndex and skinWeight based on some configuration data
  38. const y = ( vertex.y + sizing.halfHeight );
  39. const skinIndex = Math.floor( y / sizing.segmentHeight );
  40. const skinWeight = ( y % sizing.segmentHeight ) / sizing.segmentHeight;
  41. skinIndices.push( skinIndex, skinIndex + 1, 0, 0 );
  42. skinWeights.push( 1 - skinWeight, skinWeight, 0, 0 );
  43. }
  44. geometry.setAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( skinIndices, 4 ) );
  45. geometry.setAttribute( 'skinWeight', new THREE.Float32BufferAttribute( skinWeights, 4 ) );
  46. // create skinned mesh and skeleton
  47. const mesh = new THREE.SkinnedMesh( geometry, material );
  48. const skeleton = new THREE.Skeleton( bones );
  49. // see example from THREE.Skeleton
  50. const rootBone = skeleton.bones[ 0 ];
  51. mesh.add( rootBone );
  52. // bind the skeleton to the mesh
  53. mesh.bind( skeleton );
  54. // move the bones and manipulate the model
  55. skeleton.bones[ 0 ].rotation.x = -0.1;
  56. skeleton.bones[ 1 ].rotation.x = 0.2;
  57. </code>
  58. <h2>المنشئ (Constructor)</h2>
  59. <h3>
  60. [name]( [param:BufferGeometry geometry], [param:Material material] )
  61. </h3>
  62. <p>
  63. [page:BufferGeometry geometry] - نسخة من [page:BufferGeometry].<br />
  64. [page:Material material] - (اختياري) نسخة من [page:Material].
  65. الافتراضي هو [page:MeshBasicMaterial] جديد.
  66. </p>
  67. <h2>الخصائص (Properties)</h2>
  68. <p>انظر إلى الفئة الأساسية [page:Mesh] للحصول على الخصائص المشتركة.</p>
  69. <h3>[property:String bindMode]</h3>
  70. <p>
  71. Either `AttachedBindMode` or `DetachedBindMode`. `AttachedBindMode` means the skinned mesh
  72. shares the same world space as the skeleton. This is not true when using `DetachedBindMode`
  73. which is useful when sharing a skeleton across multiple skinned meshes.
  74. Default is `AttachedBindMode`.
  75. </p>
  76. <h3>[property:Matrix4 bindMatrix]</h3>
  77. <p>المصفوفة الأساسية المستخدمة لتحويلات العظام المربوطة.</p>
  78. <h3>[property:Matrix4 bindMatrixInverse]</h3>
  79. <p>المصفوفة الأساسية المستخدمة لإعادة تعيين تحويلات العظام المربوطة.</p>
  80. <h3>[property:Box3 boundingBox]</h3>
  81. <p>
  82. مربع التحديد لـ [name]. يمكن حسابه بـ
  83. [page:.computeBoundingBox](). الافتراضي هو `null`.
  84. </p>
  85. <h3>[property:Sphere boundingSphere]</h3>
  86. <p>
  87. الكرة المحيطة لـ [name]. يمكن حسابها بـ
  88. [page:.computeBoundingSphere](). الافتراضي هو `null`.
  89. </p>
  90. <h3>[property:Boolean isSkinnedMesh]</h3>
  91. <p>علامة للقراءة فقط للتحقق مما إذا كان كائن معين هو من نوع [name].</p>
  92. <h3>[property:Skeleton skeleton]</h3>
  93. <p>[page:Skeleton] يمثل هيكل العظام للشبكة المشدودة.</p>
  94. <h2>الطرق (Methods)</h2>
  95. <p>انظر إلى الفئة الأساسية [page:Mesh] للحصول على الطرق المشتركة.</p>
  96. <h3>
  97. [method:undefined bind]( [param:Skeleton skeleton], [param:Matrix4 bindMatrix] )
  98. </h3>
  99. <p>
  100. [page:Skeleton skeleton] - [page:Skeleton] تم إنشاؤه من شجرة [page:Bone Bones].<br />
  101. [page:Matrix4 bindMatrix] - [page:Matrix4] يمثل التحويل الأساسي
  102. للهيكل العظمي.<br /> <br />
  103. ربط هيكل عظمي بالشبكة المشدودة. يتم حفظ bindMatrix في
  104. خاصية .bindMatrix ويتم حساب .bindMatrixInverse.
  105. </p>
  106. <h3>[method:SkinnedMesh clone]()</h3>
  107. <p>
  108. لا تقوم هذه الطريقة حاليًا بنسخ نسخة من [name] بشكل صحيح.
  109. يرجى استخدام [page:SkeletonUtils.clone]() في هذه الأثناء.
  110. </p>
  111. <h3>[method:undefined computeBoundingBox]()</h3>
  112. <p>
  113. حساب مربع التحديد، وتحديث خاصية [page:.boundingBox].<br />
  114. لا يتم حساب مربعات التحديد افتراضيًا. يجب حسابها بشكل صريح
  115. ، وإلا كانت `null`. إذا كانت نسخة من [name] متحركة،
  116. يجب استدعاء هذه الطريقة في كل إطار لحساب مربع تحديد صحيح.
  117. </p>
  118. <h3>[method:undefined computeBoundingSphere]()</h3>
  119. <p>
  120. حساب الكرة المحيطة، وتحديث خاصية [page:.boundingSphere]
  121. .<br />
  122. لا يتم حساب الكرات المحيطة افتراضيًا. يجب حسابها بشكل صريح
  123. ، وإلا كانت `null`. إذا كانت نسخة من [name] متحركة،
  124. يجب استدعاء هذه الطريقة في كل إطار لحساب كرة محيطة صحيحة.
  125. </p>
  126. <h3>[method:undefined normalizeSkinWeights]()</h3>
  127. <p>تطبيع أوزان الجلد.</p>
  128. <h3>[method:undefined pose]()</h3>
  129. <p>هذه الطريقة تضع الشبكة المشدودة في وضعية الأساس (إعادة تعيين الوضعية).</p>
  130. <h3>
  131. [method:Vector3 applyBoneTransform]( [param:Integer index], [param:Vector3 vector] )
  132. </h3>
  133. <p>
  134. تطبق تحويل العظام المرتبط بالفهرس المعطى على موضع المتجه المعطى. يُعاد المتجه المُحدَّث.
  135. </p>
  136. <h2>المصدر (Source)</h2>
  137. <p>
  138. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  139. </p>
  140. </body>
  141. </html>