1 /* 2 Copyright 2008-2022 3 Matthias Ehmann, 4 Carsten Miller, 5 Andreas Walter, 6 Alfred Wassermann 7 8 This file is part of JSXGraph. 9 10 JSXGraph is free software dual licensed under the GNU LGPL or MIT License. 11 12 You can redistribute it and/or modify it under the terms of the 13 14 * GNU Lesser General Public License as published by 15 the Free Software Foundation, either version 3 of the License, or 16 (at your option) any later version 17 OR 18 * MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT 19 20 JSXGraph is distributed in the hope that it will be useful, 21 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 GNU Lesser General Public License for more details. 24 25 You should have received a copy of the GNU Lesser General Public License and 26 the MIT License along with JSXGraph. If not, see <http://www.gnu.org/licenses/> 27 and <http://opensource.org/licenses/MIT/>. 28 */ 29 /*global JXG:true, define: true*/ 30 31 define(['jxg'], function (JXG) { 32 "use strict"; 33 34 /** 35 * Constructs a new GeometryElement3D object. 36 * @class This is the basic class for 3D geometry elements like Point3D and Line3D. 37 * @constructor 38 * @param {string} elType 39 * @borrows JXG.EventEmitter#on as this.on 40 * @borrows JXG.EventEmitter#off as this.off 41 * @borrows JXG.EventEmitter#triggerEventHandlers as this.triggerEventHandlers 42 * @borrows JXG.EventEmitter#eventHandlers as this.eventHandlers 43 */ 44 JXG.GeometryElement3D = function (view, elType) { 45 this.elType = elType; 46 this.id = this.board.setId(this, elType); 47 48 /** 49 * Pointer to the view3D in which the elemtn is constructed 50 * @type JXG.View3D 51 * @private 52 */ 53 this.view = view; 54 55 /** 56 * Link to the 2D element(s) used to visualize the 3D element 57 * in a view. In case, there are several 2D elements, it is an array. 58 * 59 * @type JXG.GeometryElement,Array 60 * @private 61 * 62 * @example 63 * p.element2D; 64 */ 65 this.element2D = null; 66 67 /** 68 * If this property exists (and is true) the element is a 3D element. 69 * 70 * @type Boolean 71 * @private 72 */ 73 this.is3D = true; 74 this.view.objects[this.id] = this; 75 this.view.objectsList.push(this); 76 77 if (this.name !== '') { 78 this.view.elementsByName[this.name] = this; 79 } 80 81 }; 82 83 return JXG.GeometryElement3D; 84 });