*
* @method setIndexBuffer
* @for Geometry
- * @param {Object} indexBuffer PropertyBuffer to be used as a source of indices
- * for the geometry
+ * @param {Uint32Array} data The data that will be copied to the buffer
+ *
+ * @example
+ * var indexData = [0, 1, 1, 2, 2, 3, 3, 4, 4, 0];
+ * var indexDataArray = new Uint32Array(indexData.length);
+ * indexDataArray.set(indexData, 0);
+ *
+ * geometry.SetIndexBuffer( indexDataArray, indexDataArray.length );
+ *```
*/
void GeometryApi::SetIndexBuffer( const v8::FunctionCallbackInfo<v8::Value>& args )
{
Geometry geometry = GetGeometry( isolate, args );
bool found( false );
- PropertyBuffer indexBuffer = PropertyBufferApi::GetPropertyBufferFromParams( 0, found, isolate, args );
- if( !found )
+ void* data = V8Utils::GetArrayBufferViewParameter( PARAMETER_0, found, isolate, args);
+
+ if( ! found )
{
- DALI_SCRIPT_EXCEPTION( isolate, "invalid property buffer parameter" );
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid data parameter" );
}
else
{
- geometry.SetIndexBuffer(indexBuffer);
+ unsigned int size = V8Utils::GetIntegerParameter( PARAMETER_1, found, isolate, args, 0);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing buffer size from param 1" );
+ }
+ else
+ {
+ Dali::Vector<unsigned short> indices;
+ indices.Resize( size );
+ unsigned int* indexData = static_cast<unsigned int*>(data);
+ for( size_t i(0); i<size; ++i )
+ {
+ indices[i] = indexData[i];
+ }
+ geometry.SetIndexBuffer( &indices[0], size );
+ }
}
}
/**
* Set the type of primitives this geometry contains
*
- * @method setGeometryType
+ * @method setType
* @for Geometry
* @param {integer} geometryType Type of primitives this geometry contains
* @example
* dali.GEOMETRY_TRIANGLE_FAN
* dali.GEOMETRY_TRIANGLE_STRIP
*
- * geometry.SetGeometryType( dali.GEOMETRY_LINES );
+ * geometry.SetType( dali.GEOMETRY_LINES );
*/
-void GeometryApi::SetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args )
+void GeometryApi::SetType( const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );
}
else
{
- geometry.SetGeometryType(static_cast<Geometry::GeometryType>(geometryType));
+ geometry.SetType(static_cast<Geometry::Type>(geometryType));
}
}
/**
* Get the type of primitives this geometry contains
*
- * @method getGeometryType
+ * @method getType
* @for Geometry
* @return {integer} Type of primitives this geometry contains
* @example
* dali.GEOMETRY_TRIANGLE_FAN
* dali.GEOMETRY_TRIANGLE_STRIP
*/
-void GeometryApi::GetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args )
+void GeometryApi::GetType( const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );
Geometry geometry = GetGeometry( isolate, args );
- args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.GetGeometryType() ) );
+ args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.GetType() ) );
}
} // namespace V8Plugin