from direct.p3d.JavaScript import BrowserObject, ConcreteStruct, MethodWrapper, UndefinedObject

This module defines some simple classes and instances which are useful when writing code that integrates with JavaScript, especially code that runs in a browser via the web plugin.

Deprecated since version 1.10.0: The browser plug-in is no longer supported.

Inheritance diagram

Inheritance diagram of direct.p3d.JavaScript

class BrowserObject(runner, objectId)[source]

Bases: object

This class provides the Python wrapper around some object that actually exists in the plugin host’s namespace, e.g. a JavaScript or DOM object.

__init__(self, runner, objectId)[source]
class ConcreteStruct[source]

Bases: object

Python objects that inherit from this class are passed to JavaScript as a concrete struct: a mapping from string -> value, with no methods, passed by value. This can be more optimal than traditional Python objects which are passed by reference, especially for small objects which might be repeatedly referenced on the JavaScript side.


Returns a list of 2-tuples of the (key, value) pairs that are to be passed to the concrete instance. By default, this returns all properties of the object. You can override this to restrict the set of properties that are uploaded.

class MethodWrapper(runner, parentObj, objectId)[source]

Bases: object

This is a Python wrapper around a property of a BrowserObject that doesn’t appear to be a first-class object in the Python sense, but is nonetheless a callable method.

__init__(self, runner, parentObj, objectId)[source]
class UndefinedObject[source]

Bases: object

This is a special object that is returned by the browser to represent an “undefined” or “void” value, typically the value for an uninitialized variable or undefined property. It has no attributes, similar to None, but it is a slightly different concept in JavaScript.