@leafer/renderer 1.0.0-rc.1 → 1.0.0-rc.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/renderer",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.11",
4
4
  "description": "@leafer/renderer",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -15,16 +15,16 @@
15
15
  "type": "git",
16
16
  "url": "https://github.com/leaferjs/leafer.git"
17
17
  },
18
- "homepage": "https://github.com/leaferjs/leafer/tree/main/packages/renderer",
18
+ "homepage": "https://github.com/leaferjs/leafer/tree/main/packages/partner/renderer",
19
19
  "bugs": "https://github.com/leaferjs/leafer/issues",
20
20
  "keywords": [
21
21
  "leafer",
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.0.0-rc.1"
25
+ "@leafer/core": "1.0.0-rc.11"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.0.0-rc.1"
28
+ "@leafer/interface": "1.0.0-rc.11"
29
29
  }
30
30
  }
package/src/Renderer.ts CHANGED
@@ -134,7 +134,7 @@ export class Renderer implements IRenderer {
134
134
  const { canvas, updateBlocks: list } = this
135
135
  if (!list) return debug.warn('PartRender: need update attr')
136
136
 
137
- if (list.some(block => block.includes(this.target.__world))) this.mergeBlocks()
137
+ this.mergeBlocks()
138
138
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty()) this.clipRender(block) })
139
139
  }
140
140
 
@@ -144,7 +144,7 @@ export class Renderer implements IRenderer {
144
144
 
145
145
  const bounds = block.getIntersect(canvas.bounds)
146
146
  const includes = block.includes(this.target.__world)
147
- const realBounds = new Bounds().copy(bounds)
147
+ const realBounds = new Bounds(bounds)
148
148
 
149
149
  canvas.save()
150
150
 
@@ -156,7 +156,7 @@ export class Renderer implements IRenderer {
156
156
  canvas.clipWorld(bounds, true)
157
157
  }
158
158
 
159
- this.__render(bounds, realBounds)
159
+ this.__render(bounds, includes, realBounds)
160
160
  canvas.restore()
161
161
 
162
162
  Run.end(t)
@@ -168,14 +168,14 @@ export class Renderer implements IRenderer {
168
168
 
169
169
  canvas.save()
170
170
  canvas.clear()
171
- this.__render(canvas.bounds)
171
+ this.__render(canvas.bounds, true)
172
172
  canvas.restore()
173
173
 
174
174
  Run.end(t)
175
175
  }
176
176
 
177
- protected __render(bounds: IBounds, realBounds?: IBounds): void {
178
- const options: IRenderOptions = bounds?.includes(this.target.__world) ? {} : { bounds }
177
+ protected __render(bounds: IBounds, includes?: boolean, realBounds?: IBounds,): void {
178
+ const options: IRenderOptions = bounds.includes(this.target.__world) ? { includes } : { bounds, includes }
179
179
 
180
180
  if (this.needFill) this.canvas.fillWorld(bounds, this.config.fill)
181
181
  if (Debug.showRepaint) this.canvas.strokeWorld(bounds, 'red')
@@ -204,7 +204,7 @@ export class Renderer implements IRenderer {
204
204
  const { updateBlocks: list } = this
205
205
  if (list) {
206
206
  const bounds = new Bounds()
207
- bounds.setByList(list)
207
+ bounds.setList(list)
208
208
  list.length = 0
209
209
  list.push(bounds)
210
210
  }
@@ -214,10 +214,13 @@ export class Renderer implements IRenderer {
214
214
  const startTime = Date.now()
215
215
  Platform.requestRender(() => {
216
216
  this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)))
217
- if (this.changed) {
218
- if (this.running && this.canvas.view) this.render()
217
+
218
+ if (this.running) {
219
+ this.target.emit(AnimateEvent.FRAME)
220
+ if (this.changed && this.canvas.view) this.render()
221
+ this.target.emit(RenderEvent.NEXT)
219
222
  }
220
- if (this.running) this.target.emit(AnimateEvent.FRAME)
223
+
221
224
  if (this.target) this.__requestRender()
222
225
  })
223
226
  }
@@ -229,7 +232,7 @@ export class Renderer implements IRenderer {
229
232
  const bounds = new Bounds(0, 0, width, height)
230
233
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
231
234
  this.addBlock(this.canvas.bounds)
232
- this.target.forceUpdate('blendMode')
235
+ this.target.forceUpdate('surface')
233
236
  }
234
237
  }
235
238
  }
@@ -240,7 +243,7 @@ export class Renderer implements IRenderer {
240
243
  if (item.updatedList) item.updatedList.list.some(leaf => {
241
244
  empty = (!leaf.__world.width || !leaf.__world.height)
242
245
  if (empty) {
243
- if (!leaf.isLeafer) debug.warn(leaf.innerName, ': empty')
246
+ if (!leaf.isLeafer) debug.tip(leaf.innerName, ': empty')
244
247
  empty = (!leaf.isBranch || leaf.isBranchLeaf) // render object
245
248
  }
246
249
  return empty
package/types/index.d.ts CHANGED
@@ -29,7 +29,7 @@ declare class Renderer implements IRenderer {
29
29
  partRender(): void;
30
30
  clipRender(block: IBounds): void;
31
31
  fullRender(): void;
32
- protected __render(bounds: IBounds, realBounds?: IBounds): void;
32
+ protected __render(bounds: IBounds, includes?: boolean, realBounds?: IBounds): void;
33
33
  renderHitView(_options: IRenderOptions): void;
34
34
  renderBoundsView(_options: IRenderOptions): void;
35
35
  addBlock(block: IBounds): void;