JavaScript Adding indices to a BufferGeometry does not work?

I have been trying to draw a very basic rectangle using THREE.BufferGeometry(). Here is the code -

var geometry = new THREE.BufferGeometry();
var material = new THREE.MeshBasicMaterial({color: 'rgb(255, 0, 0)'});


var verticesArray = [20, 0, 0, 0, 20, 0, -20, 0, 0, 0, -20, 0];
var vertices = new Float32Array(verticesArray, 0, 12);

var indicesArray = [0, 1, 2, 0, 2, 3];
var indices = new Uint16Array(indicesArray, 0, 6);

geometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));
//geometry.addAttribute('index', new THREE.BufferAttribute(indices, 3));
geometry.setIndex(new THREE.BufferAttribute(indices, 3));


var mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);

Unfortunately it isn't working. It isn't throwing any exception either. To my understanding, i have done everything right. I have four vertices, and i have described two set of indices in counter clockwise order.

Could anyone please tell me what can go wrong here?

Answer:1

I'm running into trouble trying to use Material Design Lite and AngularJS. After googling for a bit, I found another stack overflow post regarding a similar issue: Material Design Lite Integration ...

I'm running into trouble trying to use Material Design Lite and AngularJS. After googling for a bit, I found another stack overflow post regarding a similar issue: Material Design Lite Integration ...

  1. using material design icons
  2. using material design with react
  3. using material design with angular
  4. using material design in android
  5. using material design for web
  6. using material design in android studio
  7. using material design wpf
  8. using material design icons in react
  9. using material design in xamarin forms
  10. using material design in blazor
  11. using material design with django
  12. using material design with vue.js 2
  13. using material design
  14. using material design on ios
  15. using material design in angular 6
  16. using material design icons in angular
  17. using material design in sketch
  18. using material design for websites
  19. using material design in angular 4
  20. using material design css

I'm trying to send a javascript string variable from a javascript plugin of a program running in tomcat, to a php file hosted on apache (httpd on centOS) on the same physical machine. Trying to send ...

I'm trying to send a javascript string variable from a javascript plugin of a program running in tomcat, to a php file hosted on apache (httpd on centOS) on the same physical machine. Trying to send ...

  1. ajax send javascript array
  2. ajax send javascript variable to php
  3. ajax send javascript object
  4. ajax send javascript
  5. ajax send javascript array to php
  6. ajax send javascript object to php
  7. ajax send javascript json
  8. ajax javascript send data
  9. ajax javascript send data to php
  10. ajax javascript send file
  11. ajax javascript send parameters
  12. ajax javascript send request
  13. ajax send email javascript
  14. send ajax post javascript
  15. jquery ajax send javascript object
  16. jquery ajax send javascript object to php
  17. send data ajax post javascript
  18. send parameters ajax post javascript
  19. ajax send json data javascript
  20. ajax send form data javascript

How to convert these CocoaScript “braces notation” to JavaScript “dot notation” syntax? [fileManager createDirectoryAtPath: tmpFolder withIntermediateDirectories: true attributes: nil error: nil]; ...

How to convert these CocoaScript “braces notation” to JavaScript “dot notation” syntax? [fileManager createDirectoryAtPath: tmpFolder withIntermediateDirectories: true attributes: nil error: nil]; ...

I am new to node js and create module as follow. What I got is m.add is not a function at Object.anonymous Module.js (function(exports, require, module, __filename, __dirname) { exports.add = ...

I am new to node js and create module as follow. What I got is m.add is not a function at Object.anonymous Module.js (function(exports, require, module, __filename, __dirname) { exports.add = ...

  1. node function module.export
  2. function node js
  3. function node js return
  4. function node js return value
  5. function node.js exports
  6. function node.js promise
  7. function node js express
  8. function node.js console
  9. lambda function node modules
  10. azure function node modules
  11. module function node.js
  12. private function node module
  13. module export function node js
  14. module wrapper function node js