Prototype Services
X3DProtoDeclaration
A PROTO declaration is represented by the X3DProtoDeclaration object. This object can only be fetched using the X3DExecutionContext object.
Instance Creation Method(s)
None. This object cannot be instantiated by the user.
Properties
name: string
A string of the declared name of this prototype. This property is read-only.
const scene = await Browser .createX3DFromString (`#X3D V4.0 utf8
PROFILE Interchange
PROTO MyBox [ ]
{
Shape { geometry Box { } }
}
`);
print (scene .protos [0] .name);
// Expected output: MyBox
fields: FieldDefinitionArray
A reference to FieldDefinitionArray of all the fields defined for this prototype. This property is read-only.
isExternProto: boolean
Always has the value of false. This property is read-only.
appInfo: string
Short description or purpose of the prototype.
documentation: string
A string containing the documentation of this prototype.
Methods
newInstance (): SFNode
Creates a new default instance of the prototype.
const scene = await Browser .createX3DFromString (`#X3D V4.0 utf8
PROFILE Interchange
PROTO MyBox [ ]
{
Shape { geometry Box { } }
}
`);
print (scene .protos [0] .newInstance ());
// Expected output: MyBox { }
toVRMLString (options?: Options): string non-standard
Returns the X3D VRML-encoded string that, if parsed as the value of createX3DFromString () of X3DBrowser, will produce this prototype.
For options see X3DScene.toVRMLString.
toXMLString (options?: Options): string non-standard
Returns the X3D XML-encoded string that, if parsed as the value of createX3DFromString () of X3DBrowser, will produce this prototype.
For options see X3DScene.toVRMLString.
toJSONString (options?: Options): string non-standard
Returns the X3D JSON-encoded string that, if parsed as the value of createX3DFromString () of X3DBrowser, will produce this prototype.
For options see X3DScene.toVRMLString.
X3DExternProtoDeclaration
An EXTERNPROTO declaration is represented by the X3DExternProtoDeclaration object. EXTERNPROTO declarations can only be fetched using the X3DExecutionContext object.
Instance Creation Method(s)
None. This object cannot be instantiated by the user.
Properties
name: string
A string of the declared name of this extern prototype. This property is read-only.
fields: FieldDefinitionArray
A reference to FieldDefinitionArray of all the fields defined for this extern prototype. This property is read-only.
urls: MFString
A MFString array of all the URI’s defined for this extern prototype. This property is read-only.
const scene = await Browser .createX3DFromString (`#X3D V4.0 utf8 PROFILE Interchange EXTERNPROTO MyBox [ ] "https://example.com/my-proto.x3d" `); print (scene .externprotos [0] .urls); // Expected output: "https://example.com/my-proto.x3d"
isExternProto: boolean
Always has the value of true. This property is read-only.
loadState: number
The value is one of the _STATE properties defined in the X3DConstants object. This property is read-only.
appInfo: string
Short description or purpose of the extern prototype.
documentation: string
A string containing the documentation of this extern prototype.
Methods
newInstance (): SFNode
Creates a new default instance of the extern prototype.
loadNow (): Promise<void>
Triggers the loading of the extern prototype. It returns a Promise that is resolved when the extern prototype is completely loaded and all instances are updated.
toVRMLString (options?: Options): string
Returns the X3D VRML-encoded string that, if parsed as the value of createX3DFromString () of X3DBrowser, will produce this extern prototype.
For options see X3DScene.toVRMLString.
toXMLString (options?: Options): string
Returns the X3D XML-encoded string that, if parsed as the value of createX3DFromString () of X3DBrowser, will produce this extern prototype.
For options see X3DScene.toVRMLString.
const scene = await Browser .createX3DFromString (`#X3D V4.0 utf8 PROFILE Interchange EXTERNPROTO MyBox [ ] "https://example.com/my-proto.x3d" `); print (scene .externprotos [0] .toXMLString ());
toJSONString (options?: Options): string
Returns the X3D JSON-encoded string that, if parsed as the value of createX3DFromString () of X3DBrowser, will produce this extern prototype.
For options see X3DScene.toVRMLString.
ProtoDeclarationArray
ProtoDeclarationArray is an object that represents an array of X3DProtoDeclaration objects. This is a read-only object. Individual elements of the array can be referenced using the standard C-style dereferencing operator (e.g. protoDeclarationArrayName[index], where index is an integer-valued expression with 0<=index<length and length is the number of elements in the array).
Instance Creation Method(s)
None. This object cannot be instantiated by the user.
Iterator
The [@@iterator]() method of ProtoDeclarationArray instances implements the iterable protocol and allows ProtoDeclarationArray objects to be consumed by most syntaxes expecting iterables, such as the spread syntax and for...of loops. It returns an iterator object that yields the object’s properties in order.
Properties
length: number
An integer containing the number of elements in the array. This property is read-only.
Methods
Almost all read-only functions known from JavaScript Array.
ExternProtoDeclarationArray
ExternProtoDeclarationArray is an object that represents an array of X3DExternProtoDeclaration objects. This is a read-only object. Individual elements of the array can be referenced using the standard C-style dereferencing operator (e.g. externProtoDeclarationArrayName[index], where index is an integer-valued expression with 0<=index<length and length is the number of elements in the array).
Instance Creation Method(s)
None. This object cannot be instantiated by the user.
Iterator
The [@@iterator]() method of ExternProtoDeclarationArray instances implements the iterable protocol and allows ExternProtoDeclarationArray objects to be consumed by most syntaxes expecting iterables, such as the spread syntax and for...of loops. It returns an iterator object that yields the object’s properties in order.
Properties
length: number
An integer containing the number of elements in the array. This property is read-only.
Methods
Almost all read-only functions known from JavaScript Array.