Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Parser

解析已下载的文件,parser 是一个单例, 所有成员能通过 cc.assetManaager.parser 访问

Hierarchy

  • Parser

Index

Properties

Private parsing

parsing: Cache<((err: Error | null, data?: T | null) => void)[]> = new Cache<CompleteCallback[]>()

Methods

init

  • init(): void

parse

  • parse(id: string, file: any, type: string, options: IDownloadParseOptions, onComplete: CompleteCallback): void
  • 使用对应的handler来解析文件

    example

    downloader.download('test.jpg', 'test.jpg', '.jpg', {}, (err, file) => { parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err)); });

    Parameters

    • id: string

      The id of file

    • file: any

      File

    • type: string

      The corresponding type of file, likes '.jpg'.

    • options: IDownloadParseOptions

      Some optional paramters will be transferred to the corresponding handler.

    • onComplete: CompleteCallback

      callback when finishing downloading

    Returns void

parseASTCTex

  • parseASTCTex(file: ArrayBuffer | ArrayBufferView, options: IDownloadParseOptions, onComplete: CompleteCallback<IMemoryImageSource>): void

parseAudio

  • parseAudio(file: ArrayBuffer | HTMLAudioElement, options: IDownloadParseOptions, onComplete: CompleteCallback<AudioBuffer | HTMLAudioElement>): void
  • Parameters

    • file: ArrayBuffer | HTMLAudioElement
    • options: IDownloadParseOptions
    • onComplete: CompleteCallback<AudioBuffer | HTMLAudioElement>

    Returns void

parseImage

  • parseImage(file: HTMLImageElement | Blob, options: IDownloadParseOptions, onComplete: CompleteCallback<HTMLImageElement | ImageBitmap>): void
  • Parameters

    • file: HTMLImageElement | Blob
    • options: IDownloadParseOptions
    • onComplete: CompleteCallback<HTMLImageElement | ImageBitmap>

    Returns void

parseImport

  • parseImport(file: Record<string, any>, options: IDownloadParseOptions, onComplete: CompleteCallback<Asset>): void

parsePKMTex

  • parsePKMTex(file: ArrayBuffer | ArrayBufferView, options: IDownloadParseOptions, onComplete: CompleteCallback<IMemoryImageSource>): void

parsePVRTex

  • parsePVRTex(file: ArrayBuffer | ArrayBufferView, options: IDownloadParseOptions, onComplete: CompleteCallback<IMemoryImageSource>): void

parsePlist

  • parsePlist(file: string, options: IDownloadParseOptions, onComplete: CompleteCallback): void

register

  • 当你想修改默认行为或者拓展 parser 来解析其他格式文件时可以注册自定义的handler

    example

    parser.register('.tga', (file, options, onComplete) => onComplete(null, null)); parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)});

    Parameters

    • type: string

      Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler}

    • handler: ParseHandler

      The corresponding handler

    Returns void

  • Parameters

    Returns void

Object literals

Private parsers

parsers: object

.astc

.astc: parseASTCTex = this.parseASTCTex

.bmp

.bmp: parseImage = this.parseImage

.gif

.gif: parseImage = this.parseImage

.ico

.ico: parseImage = this.parseImage

.image

.image: parseImage = this.parseImage

.jpeg

.jpeg: parseImage = this.parseImage

.jpg

.jpg: parseImage = this.parseImage

.m4a

.m4a: parseAudio = this.parseAudio

.mp3

.mp3: parseAudio = this.parseAudio

.ogg

.ogg: parseAudio = this.parseAudio

.pkm

.pkm: parsePKMTex = this.parsePKMTex

.plist

.plist: parsePlist = this.parsePlist

.png

.png: parseImage = this.parseImage

.pvr

.pvr: parsePVRTex = this.parsePVRTex

.tiff

.tiff: parseImage = this.parseImage

.wav

.wav: parseAudio = this.parseAudio

.webp

.webp: parseImage = this.parseImage

import

import: parseImport = this.parseImport

Generated using TypeDoc