MCPcopy
hub / github.com/donmccurdy/glTF-Transform / createPrimitive

Function createPrimitive

packages/functions/test/quantize.test.ts:492–569  ·  view source on GitHub ↗
(doc: Document)

Source from the content-addressed store, hash-verified

490}
491
492function createPrimitive(doc: Document): Primitive {
493 const prim = doc
494 .createPrimitive()
495 .setMode(Primitive.Mode.TRIANGLES)
496 .setAttribute(
497 'POSITION',
498 doc
499 .createAccessor('POSITION')
500 .setType('VEC3')
501 .setArray(new Float32Array([10, 10, 0, 10, 15, 0, 15, 10, 0, 15, 15, 0, 10, 10, 0])),
502 )
503 .setAttribute(
504 'TEXCOORD_0',
505 doc
506 .createAccessor('TEXCOORD_0')
507 .setType('VEC2')
508 .setArray(new Float32Array([0.0, 0.0, 0.5, 0.5, 0.75, 0.25, 1.0, 0.0, 1.0, 1.0])),
509 )
510 .setAttribute(
511 'NORMAL',
512 doc
513 .createAccessor('NORMAL')
514 .setType('VEC3')
515 .setArray(
516 new Float32Array([
517 -0.19211, -0.93457, 0.29946, -0.08526, -0.99393, 0.06957, 0.82905, -0.39715, 0.39364, 0.37303,
518 -0.68174, 0.62934, -0.06048, 0.04752, 0.99704,
519 ]),
520 ),
521 )
522 .setAttribute(
523 'TANGENT',
524 doc
525 .createAccessor('TANGENT')
526 .setType('VEC4')
527 .setArray(
528 new Float32Array([
529 -0.19211, -0.93457, 0.29946, 1.0, -0.08526, -0.99393, 0.06957, -1.0, 0.82905, -0.39715, 0.39364,
530 1.0, 0.37303, -0.68174, 0.62934, 1.0, -0.06048, 0.04752, 0.99704, -1.0,
531 ]),
532 ),
533 )
534 .setAttribute(
535 'COLOR_0',
536 doc
537 .createAccessor('COLOR_0')
538 .setType('VEC3')
539 .setArray(
540 new Float32Array([
541 0.19, 0.93, 0.29, 0.08, 0.99, 0.06, 0.82, 0.39, 0.39, 0.37, 0.68, 0.62, 0.06, 0.04, 0.99,
542 ]),
543 ),
544 )
545 .setAttribute(
546 'JOINTS_0',
547 doc
548 .createAccessor('JOINTS_0')
549 .setType('VEC4')

Callers 1

quantize.test.tsFile · 0.70

Calls 12

setModeMethod · 0.80
createPrimitiveMethod · 0.80
createAccessorMethod · 0.80
createSceneMethod · 0.80
setMeshMethod · 0.80
createNodeMethod · 0.80
addPrimitiveMethod · 0.80
createMeshMethod · 0.80
setAttributeMethod · 0.45
setArrayMethod · 0.45
setTypeMethod · 0.45
addChildMethod · 0.45

Tested by

no test coverage detected