Skip to content

Commit b336638

Browse files
author
Don McCurdy
committed
Fix some type issues, remove strict:false
1 parent 1446bf6 commit b336638

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

examples/website/plot/plot-layer/axes-layer.ts

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ export type AxesLayerProps<DataT = unknown> = _AxesLayerProps<DataT> & LayerProp
4949
type _AxesLayerProps<DataT> = {
5050
data: LayerDataSource<DataT>;
5151
fontSize: number;
52-
xScale?: ScaleLinear<number, number>;
53-
yScale?: ScaleLinear<number, number>;
54-
zScale?: ScaleLinear<number, number>;
52+
xScale: ScaleLinear<number, number>;
53+
yScale: ScaleLinear<number, number>;
54+
zScale: ScaleLinear<number, number>;
5555
xTicks: number;
5656
yTicks: number;
5757
zTicks: number;
@@ -99,7 +99,7 @@ export default class AxesLayer<DataT = any, ExtraPropsT extends {} = {}> extends
9999
declare state: Layer['state'] & {
100100
models: [Model, Model];
101101
modelsByName: {grids: Model; labels: Model};
102-
instanceCount: number;
102+
numInstances: number;
103103
ticks: [Tick[], Tick[], Tick[]];
104104
gridDims: Vec3;
105105
gridCenter: Vec3;
@@ -108,19 +108,19 @@ export default class AxesLayer<DataT = any, ExtraPropsT extends {} = {}> extends
108108

109109
initializeState() {
110110
const {gl} = this.context;
111-
const attributeManager = this.getAttributeManager();
111+
const attributeManager = this.getAttributeManager()!;
112112

113113
attributeManager.addInstanced({
114114
instancePositions: {size: 2, update: this.calculateInstancePositions, noAlloc: true},
115115
instanceNormals: {size: 3, update: this.calculateInstanceNormals, noAlloc: true},
116116
instanceIsTitle: {size: 1, update: this.calculateInstanceIsTitle, noAlloc: true}
117117
});
118118

119-
this.setState(Object.assign({instanceCount: 0}, this._getModels(gl)));
119+
this.setState(Object.assign({numInstances: 0}, this._getModels(gl)));
120120
}
121121

122122
updateState({oldProps, props, changeFlags}) {
123-
const attributeManager = this.getAttributeManager();
123+
const attributeManager = this.getAttributeManager()!;
124124

125125
if (
126126
oldProps.xScale !== props.xScale ||
@@ -161,13 +161,8 @@ export default class AxesLayer<DataT = any, ExtraPropsT extends {} = {}> extends
161161
}
162162

163163
draw({uniforms}) {
164-
const {
165-
gridDims,
166-
gridCenter,
167-
modelsByName,
168-
labelTexture: {labelTexture, ...labelTextureUniforms},
169-
instanceCount
170-
} = this.state;
164+
const {gridDims, gridCenter, modelsByName, numInstances} = this.state;
165+
const {labelTexture, ...labelTextureUniforms} = this.state.labelTexture!;
171166
const {fontSize, color, padding} = this.props;
172167

173168
if (labelTexture) {
@@ -179,8 +174,8 @@ export default class AxesLayer<DataT = any, ExtraPropsT extends {} = {}> extends
179174
strokeColor: color
180175
};
181176

182-
modelsByName.grids.setInstanceCount(instanceCount);
183-
modelsByName.labels.setInstanceCount(instanceCount);
177+
modelsByName.grids.setInstanceCount(numInstances);
178+
modelsByName.labels.setInstanceCount(numInstances);
184179

185180
modelsByName.grids.setUniforms(Object.assign({}, uniforms, baseUniforms));
186181
modelsByName.labels.setBindings({labelTexture});
@@ -240,7 +235,7 @@ export default class AxesLayer<DataT = any, ExtraPropsT extends {} = {}> extends
240235
id: `${this.props.id}-grids`,
241236
vs: gridVertex,
242237
fs: fragmentShader,
243-
bufferLayout: this.getAttributeManager().getBufferLayouts(),
238+
bufferLayout: this.getAttributeManager()!.getBufferLayouts(),
244239
geometry: new Geometry({
245240
topology: 'line-list',
246241
attributes: {
@@ -289,7 +284,7 @@ export default class AxesLayer<DataT = any, ExtraPropsT extends {} = {}> extends
289284
id: `${this.props.id}-labels`,
290285
vs: labelVertex,
291286
fs: labelFragment,
292-
bufferLayout: this.getAttributeManager().getBufferLayouts(),
287+
bufferLayout: this.getAttributeManager()!.getBufferLayouts(),
293288
geometry: new Geometry({
294289
topology: 'triangle-list',
295290
attributes: {
@@ -315,7 +310,7 @@ export default class AxesLayer<DataT = any, ExtraPropsT extends {} = {}> extends
315310
const value = new Float32Array(flatten(positions));
316311
attribute.value = value;
317312

318-
this.setState({instanceCount: value.length / attribute.size});
313+
this.setState({numInstances: value.length / attribute.size});
319314
}
320315

321316
calculateInstanceNormals(attribute) {
@@ -381,7 +376,7 @@ function getTicks(props: AxesLayerProps<number> & {axis: Axis}): Tick[] {
381376
const tickFormat = props[`${axis}TickFormat`];
382377

383378
if (!Array.isArray(ticks)) {
384-
ticks = scale.ticks(ticks);
379+
ticks = scale.ticks(ticks) as number[];
385380
}
386381

387382
const titleTick = {

examples/website/plot/plot-layer/surface-layer.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export default class SurfaceLayer<DataT = any, ExtraPropsT extends {} = {}> exte
105105
fs: fragmentShader,
106106
modules: [picking],
107107
topology: 'triangle-list',
108-
bufferLayout: this.getAttributeManager().getBufferLayouts(),
108+
bufferLayout: this.getAttributeManager()!.getBufferLayouts(),
109109
vertexCount: 0
110110
});
111111
}
@@ -126,29 +126,29 @@ export default class SurfaceLayer<DataT = any, ExtraPropsT extends {} = {}> exte
126126
* 0--------> 1
127127
* x
128128
*/
129-
encodePickingColor(i: number) {
129+
encodePickingColor(i: number, target: number[] = []) {
130130
const {uCount, vCount} = this.props;
131131

132132
const xIndex = i % uCount;
133133
const yIndex = (i - xIndex) / uCount;
134134

135-
return [(xIndex / (uCount - 1)) * 255, (yIndex / (vCount - 1)) * 255, 1] as $TODO;
135+
return [(xIndex / (uCount - 1)) * 255, (yIndex / (vCount - 1)) * 255, 1];
136136
}
137137

138138
decodePickingColor([r, g, b]: Color): number {
139139
if (b === 0) {
140140
return -1;
141141
}
142-
return [r / 255, g / 255] as $TODO;
142+
return r | g << 8;
143143
}
144144

145145
getPickingInfo(opts) {
146146
const {info} = opts;
147147

148148
if (info && info.index !== -1) {
149-
const [u, v] = info.index;
150149
const {getPosition} = this.props;
151-
150+
const u = (info.index & 255) / 255;
151+
const v = (info.index >> 8) / 255;
152152
info.sample = getPosition(u, v);
153153
}
154154

@@ -227,7 +227,7 @@ export default class SurfaceLayer<DataT = any, ExtraPropsT extends {} = {}> exte
227227
const {vertexCount} = this.state;
228228

229229
// reuse the calculated [x, y, z] in positions
230-
const positions = this.getAttributeManager()!.attributes.positions.value;
230+
const positions = this.getAttributeManager()!.attributes.positions.value!;
231231
const value = new Uint8ClampedArray(vertexCount! * attribute.size);
232232

233233
// Support constant colors
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"extends": "../../../tsconfig.json",
3-
"include": ["./**/*.ts"],
4-
"compilerOptions": { "strict": false }
3+
"include": ["./**/*.ts"]
54
}

0 commit comments

Comments
 (0)