Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!isWeixinApp() && opts.forceFit) {
opts.viewport = 'auto'
} else {
opts.viewport = opts.size ? opts.size : [opts.width, opts.height]
}
/**
{
vwr: 1,
layer: 'fglayer',
}
*/
if (isWeixinApp()) {
let [width, height] = opts.viewport;
let pixelRatio = opts.pixelRatio || 'px';
this.scene = new Scene(Number(width) || null, Number(height) || null, pixelRatio);
} else {
this.scene = new Scene(container, {
displayRatio: 'auto',
...opts
})
}
const layerID = opts.layer || 'default'
if (isWeixinApp()) {
this.layer = this.scene.layer(layerID, opts.component)
} else {
this.layer = this.scene.layer(layerID)
}
if (isDev) {
this.layer.on('update', debounce(() => {
console.info(
} else {
opts.viewport = opts.size ? opts.size : [opts.width, opts.height]
}
/**
{
vwr: 1,
layer: 'fglayer',
}
*/
if (isWeixinApp()) {
let [width, height] = opts.viewport;
let pixelRatio = opts.pixelRatio || 'px';
this.scene = new Scene(Number(width) || null, Number(height) || null, pixelRatio);
} else {
this.scene = new Scene(container, {
displayRatio: 'auto',
...opts
})
}
const layerID = opts.layer || 'default'
if (isWeixinApp()) {
this.layer = this.scene.layer(layerID, opts.component)
} else {
this.layer = this.scene.layer(layerID)
}
if (isDev) {
this.layer.on('update', debounce(() => {
console.info(
`%c如果持续打印该信息,说明 layer 在不断重绘,需要找出问题!`,
'color: red'
componentDidMount() {
this._scene = new Scene(this.refs.scene, this.props);
this._mountNode = SpriteRender.createContainer(this._scene);
SpriteRender.updateContainer(this.props.children, this._mountNode, this);
}
installed() {
if(this.shadowRoot && this.shadowRoot.styleSheets) {
stylesheet.fromDocumentCSS(this.shadowRoot.styleSheets)
}
let node = this
while(node) {
const styleSheets = node.styleSheets
if(styleSheets) {
stylesheet.fromDocumentCSS(styleSheets)
}
node = node.parentNode
}
this.scene = new Scene(this.container, this.props)
render(this.scene, this.props.children)
}