-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support multiple canvas instances #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
1471b9a
fix init asset
MinCrohn 81fd91b
fix export undoredomanger
MinCrohn f7145bd
fix pipeline name
MinCrohn 51b8323
fix undoredomanager instance
MinCrohn 710f24a
fix local renderer
MinCrohn a529ab4
apply context object pattern
MinCrohn 1e43adc
fix getColor
MinCrohn ffef39d
fix theme
MinCrohn 1eb1e6d
fix
MinCrohn c0df91a
refactor draw & update
MinCrohn 3f63231
fix gsap context
MinCrohn ed3ca4a
fix percentHeight condition
MinCrohn 9ccc148
fix
MinCrohn ad6a95b
fix select event
MinCrohn 5e8f194
fix
MinCrohn fa350ff
fix deepmerge
MinCrohn 538805c
delete Assets.reset
MinCrohn bd57c8b
fix destroy
MinCrohn 480525f
fix init asset
MinCrohn bc88760
init select event
MinCrohn 9a3d8a3
fix
MinCrohn aa1cdb6
fix
MinCrohn 38888ff
fix details
MinCrohn ccdd7cc
add undoredoManager destroy method
MinCrohn d29d975
fix
MinCrohn 79a5b15
fix naming
MinCrohn fc0fea2
fix
MinCrohn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,26 @@ | ||
| import { Assets, Cache } from 'pixi.js'; | ||
| import { Assets } from 'pixi.js'; | ||
| import { createRectTexture } from './rect'; | ||
| import { cacheKey } from './utils'; | ||
|
|
||
| export const getTexture = (config) => { | ||
| export const getTexture = (renderer, theme, config) => { | ||
| let texture = null; | ||
| if (typeof config === 'string') { | ||
| texture = Assets.get(config); | ||
| } else { | ||
| texture = Cache.has(cacheKey(config)) | ||
| ? Assets.get(cacheKey(config)) | ||
| : createTexture(config); | ||
| texture = Assets.cache.has(cacheKey(renderer, config)) | ||
| ? Assets.cache.get(cacheKey(renderer, config)) | ||
| : createTexture(renderer, theme, config); | ||
MinCrohn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return texture; | ||
| }; | ||
|
|
||
| export const createTexture = (config) => { | ||
| export const createTexture = (renderer, theme, config) => { | ||
| let texture = null; | ||
| switch (config.type) { | ||
| case 'rect': | ||
| texture = createRectTexture(config); | ||
| texture = createRectTexture(renderer, theme, config); | ||
| break; | ||
| } | ||
| Cache.set(cacheKey(config), texture); | ||
| Assets.cache.set(cacheKey(renderer, config), texture); | ||
| return texture; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,22 @@ | ||
| import { TextureStyle } from '../../display/data-schema/component-schema'; | ||
| import { deepMerge } from '../../utils/deepmerge/deepmerge'; | ||
| import { renderer } from '../../utils/renderer'; | ||
|
|
||
| const RESOLUTION = 5; | ||
|
|
||
| export const generateTexture = (target = null, opts = {}) => { | ||
| export const generateTexture = (target, renderer, opts = {}) => { | ||
MinCrohn marked this conversation as resolved.
Show resolved
Hide resolved
MinCrohn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const options = deepMerge({ resolution: RESOLUTION }, opts); | ||
| if (!target) return; | ||
|
|
||
| const texture = renderer.get().generateTexture({ | ||
| const texture = renderer.generateTexture({ | ||
| target, | ||
| resolution: options.resolution, | ||
| }); | ||
| return texture; | ||
| }; | ||
|
|
||
| export const cacheKey = (config) => { | ||
| return TextureStyle.keyof() | ||
| .options.map((key) => config[key]) | ||
| .join('-'); | ||
| export const cacheKey = (renderer, config) => { | ||
| return [ | ||
| renderer.uid, | ||
| ...TextureStyle.keyof().options.map((key) => config[key]), | ||
| ].join('-'); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| import * as commands from './commands'; | ||
| import { UndoRedoManager } from './undo-redo-manager'; | ||
|
|
||
| export const Commands = commands; | ||
| export const undoRedoManager = new UndoRedoManager(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,12 @@ | ||
| import { undoRedoManager } from '../../../command'; | ||
|
|
||
| export const createCommandHandler = (Command, changeFn) => { | ||
| return (object, config, options) => { | ||
| const { undoRedoManager } = options; | ||
| if (options?.historyId) { | ||
| undoRedoManager.execute(new Command(object, config), { | ||
| undoRedoManager.execute(new Command(object, config, options), { | ||
| historyId: options.historyId, | ||
| }); | ||
| } else { | ||
| changeFn(object, config); | ||
| changeFn(object, config, options); | ||
| } | ||
| }; | ||
MinCrohn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.