Hi, I am working on a vector class.
I want the user to be able to do this:
myvec.x = 3;
print(myvec.x);
and also
myvec[0] = 3;
print(myvec[0]);
I tried this:
Handle<Value> ConstructVec3(const v8::Arguments& args)
{
// extract vec3 from argument
osg::Vec3& vec =
*static_cast<osg::Vec3*>(v8::External::Unwrap(args[0]));
HandleScope handle_scope;
args[0]->ToNumber
Local<Value> x = Number::New(vec[0]);
Local<Value> y = Number::New(vec[1]);
Local<Value> z = Number::New(vec[2]);
args.This()->Set(String::New("x"), x);
args.This()->Set(Integer::New(0), x);
args.This()->Set(String::New("y"), y);
args.This()->Set(Integer::New(1), y);
args.This()->Set(String::New("z"), z);
args.This()->Set(Integer::New(2), z);
return args.This();
}
But when I set myvec.x = 3 then myvec[0] still has the same value.
What can I do?
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users