(props?: CubeLayerProps)
| 62 | }; |
| 63 | |
| 64 | function _CubeLayer(props?: CubeLayerProps) { |
| 65 | |
| 66 | //dynamic superclass, since we don't know have deck.Layer in the declaration phase |
| 67 | class __CubeLayer extends base.deck.Layer<Cube> { |
| 68 | |
| 69 | static layerName = 'CubeLayer'; |
| 70 | static defaultProps = defaultProps; |
| 71 | |
| 72 | public id: string; |
| 73 | public props: CubeLayerProps; |
| 74 | |
| 75 | getShaders() { |
| 76 | return { vs, fs, modules: [base.deck.project32, base.deck.gouraudLighting, base.deck.picking] }; |
| 77 | } |
| 78 | |
| 79 | initializeState() { |
| 80 | const attributeManager = this.getAttributeManager(); |
| 81 | attributeManager.addInstanced({ |
| 82 | instancePositions: { |
| 83 | size: 3, |
| 84 | type: DOUBLE, |
| 85 | transition: true, |
| 86 | accessor: 'getPosition', |
| 87 | }, |
| 88 | instanceSizes: { |
| 89 | size: 3, |
| 90 | transition: true, |
| 91 | accessor: 'getSize', |
| 92 | }, |
| 93 | instanceColors: { |
| 94 | size: 4, |
| 95 | type: UNSIGNED_BYTE, |
| 96 | transition: true, |
| 97 | accessor: 'getColor', |
| 98 | defaultValue: DEFAULT_COLOR, |
| 99 | }, |
| 100 | }); |
| 101 | } |
| 102 | |
| 103 | updateState({ props, oldProps, changeFlags }) { |
| 104 | super.updateState({ props, oldProps, changeFlags } as any); //TODO add parameter type to deck.gl-typings |
| 105 | // Re-generate model if geometry changed |
| 106 | //if (props.fp64 !== oldProps.fp64) { |
| 107 | const { gl } = this.context; |
| 108 | if (this.state.model) { |
| 109 | this.state.model.delete(); |
| 110 | } |
| 111 | this.setState({ model: this._getModel(gl) }); |
| 112 | this.getAttributeManager().invalidateAll(); |
| 113 | //} |
| 114 | } |
| 115 | |
| 116 | _getModel(gl) { |
| 117 | return new base.luma.Model( |
| 118 | gl, |
| 119 | Object.assign({}, this.getShaders(), { |
| 120 | id: this.props.id, |
| 121 | geometry: new base.luma.CubeGeometry(), |
nothing calls this directly
no outgoing calls
no test coverage detected