123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- define([
- '../Core/Cartesian3',
- '../Core/Color',
- '../Core/defaultValue',
- '../Core/defined',
- '../Core/destroyObject',
- '../Core/GeometryInstance',
- '../Core/Matrix4',
- '../Core/PolylineGeometry',
- './PolylineColorAppearance',
- './Primitive'
- ], function(
- Cartesian3,
- Color,
- defaultValue,
- defined,
- destroyObject,
- GeometryInstance,
- Matrix4,
- PolylineGeometry,
- PolylineColorAppearance,
- Primitive) {
- "use strict";
-
- var DebugModelMatrixPrimitive = function(options) {
- options = defaultValue(options, defaultValue.EMPTY_OBJECT);
-
- this.length = defaultValue(options.length, 10000000.0);
- this._length = undefined;
-
- this.width = defaultValue(options.width, 2.0);
- this._width = undefined;
-
- this.show = defaultValue(options.show, true);
-
- this.modelMatrix = Matrix4.clone(defaultValue(options.modelMatrix, Matrix4.IDENTITY));
- this._modelMatrix = new Matrix4();
-
- this.id = options.id;
- this._id = undefined;
- this._primitive = undefined;
- };
-
- DebugModelMatrixPrimitive.prototype.update = function(context, frameState, commandList) {
- if (!this.show) {
- return;
- }
- if (!defined(this._primitive) ||
- (!Matrix4.equals(this._modelMatrix, this.modelMatrix)) ||
- (this._length !== this.length) ||
- (this._width !== this.width) ||
- (this._id !== this.id)) {
- this._modelMatrix = Matrix4.clone(this.modelMatrix, this._modelMatrix);
- this._length = this.length;
- this._width = this.width;
- this._id = this.id;
- if (defined(this._primitive)) {
- this._primitive.destroy();
- }
-
- if ((this.modelMatrix[12] === 0.0 && this.modelMatrix[13] === 0.0 && this.modelMatrix[14] === 0.0)) {
- this.modelMatrix[14] = 0.01;
- }
- var x = new GeometryInstance({
- geometry : new PolylineGeometry({
- positions : [
- Cartesian3.ZERO,
- Cartesian3.UNIT_X
- ],
- width : this.width,
- vertexFormat : PolylineColorAppearance.VERTEX_FORMAT,
- colors : [
- Color.RED,
- Color.RED
- ],
- followSurface: false
- }),
- modelMatrix : Matrix4.multiplyByUniformScale(this.modelMatrix, this.length, new Matrix4()),
- id : this.id,
- pickPrimitive : this
- });
- var y = new GeometryInstance({
- geometry : new PolylineGeometry({
- positions : [
- Cartesian3.ZERO,
- Cartesian3.UNIT_Y
- ],
- width : this.width,
- vertexFormat : PolylineColorAppearance.VERTEX_FORMAT,
- colors : [
- Color.GREEN,
- Color.GREEN
- ],
- followSurface: false
- }),
- modelMatrix : Matrix4.multiplyByUniformScale(this.modelMatrix, this.length, new Matrix4()),
- id : this.id,
- pickPrimitive : this
- });
- var z = new GeometryInstance({
- geometry : new PolylineGeometry({
- positions : [
- Cartesian3.ZERO,
- Cartesian3.UNIT_Z
- ],
- width : this.width,
- vertexFormat : PolylineColorAppearance.VERTEX_FORMAT,
- colors : [
- Color.BLUE,
- Color.BLUE
- ],
- followSurface: false
- }),
- modelMatrix : Matrix4.multiplyByUniformScale(this.modelMatrix, this.length, new Matrix4()),
- id : this.id,
- pickPrimitive : this
- });
- this._primitive = new Primitive({
- geometryInstances : [x, y, z],
- appearance : new PolylineColorAppearance(),
- asynchronous : false
- });
- }
- this._primitive.update(context, frameState, commandList);
- };
-
- DebugModelMatrixPrimitive.prototype.isDestroyed = function() {
- return false;
- };
-
- DebugModelMatrixPrimitive.prototype.destroy = function() {
- this._primitive = this._primitive && this._primitive.destroy();
- return destroyObject(this);
- };
- return DebugModelMatrixPrimitive;
- });
|