Core Classes for 3D
Below are additional details on the design of the additional classes for the 3D exnteions to CanvasMap.
New areas
The following are new areas (including base classes) for managing 3D maps:
- Cameras
- Controls
- Lights
- Materials
- THREEBase
There are also new utilities and other classes:
- Utilities:
- CM3Defs
- CM3DrapeGeometry
- CM3Utilites
- Projectors:
- CMProjectorSpherical
- Items:
- CM3Item, CM3ItemPoly, CM3ItemBox, CMNorthArrow, CM3Text
- Layers:
- CM3Layer, CM3LayerItems, CM3LayerLights
- Geos:
- CM3Geo
- Scenes:
- CM3Scene
- Views:
- CM3View
- Lights
- CM3Light
- Materials
- CM3Material
Core Classes
CM3Item
CMBase Functions
A CM3Item inherits from CMItem and appears in a CM3Scene, CM3Geo, or another CM3Item. CM3Items add:
- A THREEBase that is added to the parent's THREEBase when:
- If the parent's THREEBase exists, when the child is added to the parent
- Or when the parent's THREEBase is created
- The THREEBase's visible value is used to control visibility in the 3D Scene
- An optional CM3Material as a child item or a THREEMaterial that is set directly
- Handling of mouse events for 3D items
- Settings:
- Positioning of the items in 3D space
One problem is that there is significant code in the 2D classes that would be replicated in a number of the 3D classes. In OOD terms, should something like a CM3Layer inherit from it's related parent class or inherit from CM3Item? Since JavaScript does not support muitple inheritance, the classes that can inherit from CM3Item do while other classes inherit from their 2D counterpart and then they replicate the CM3Item funcionality. To limit the amount of code, the CM3Item's functions are represented by static functions that can be called by the other 3D classes. We refer to this as "Item-Like" inheritance.
Overriden functions:
- AddChild(TheChild)
- If TheChild is a CMMaterial object
- Removes and deallocates any existing CMMaterial child objects
- MaterialSetExternally=true
- Sets the current objects material to TheChild's material
- else
- Calls repaint
- If TheChild is a CMMaterial object
- RemoveChild()
- Removes child object from scene, if any
- Deallocate()
- this.Reset()
- Calls parent to remove children and repaint
- Paint()
- calls initialize and then calls children to paint (without setting up style)
- calls children to paint
- SetSettings() - should only set settings if the object is initalized (should not call initialize)
- Initialize() - jjg add to CMItem?
- Reset()
Additional CM3Item functions :
- GetTHREEGeometry()
- GetTHREEMaterial()
- SetTHREEMaterial()
- GetTHREEMesh() - create the mesh
- GetTHREEBase() - initialize the base object?
- SetTHREEBase()
- GetTHREEHead() - initialize the hed object?
- AddTHREEObject()
- RemoveTHREEObject()
- SetTHREEObjectVisible()
- InitializeChildren
- Initialize
CM3Scene
Inherits from CMScene rather than CM3Item.
- GetTHREEBase() -> GetTHREEBase()?